Lines Matching refs:fd
49 static bool ReadProtocolString(int fd, std::string* s, std::string* error) { in ReadProtocolString() argument
51 if (!ReadFdExactly(fd, buf, 4)) { in ReadProtocolString()
59 if (!ReadFdExactly(fd, &(*s)[0], len)) { in ReadProtocolString()
113 static int switch_socket_transport(int fd, std::string* error) { in switch_socket_transport() argument
138 if (!SendProtocolString(fd, service)) { in switch_socket_transport()
140 adb_close(fd); in switch_socket_transport()
145 if (!adb_status(fd, error)) { in switch_socket_transport()
146 adb_close(fd); in switch_socket_transport()
154 bool adb_status(int fd, std::string* error) { in adb_status() argument
156 if (!ReadFdExactly(fd, buf, 4)) { in adb_status()
171 ReadProtocolString(fd, error, error); in adb_status()
183 int fd; in _adb_connect() local
185 fd = socket_network_client(__adb_server_name, __adb_server_port, SOCK_STREAM); in _adb_connect()
187 fd = socket_loopback_client(__adb_server_port, SOCK_STREAM); in _adb_connect()
189 if (fd < 0) { in _adb_connect()
194 if (memcmp(&service[0],"host",4) != 0 && switch_socket_transport(fd, error)) { in _adb_connect()
198 if(!SendProtocolString(fd, service)) { in _adb_connect()
200 adb_close(fd); in _adb_connect()
204 if (!adb_status(fd, error)) { in _adb_connect()
205 adb_close(fd); in _adb_connect()
209 D("_adb_connect: return fd %d\n", fd); in _adb_connect()
210 return fd; in _adb_connect()
215 int fd = _adb_connect("host:version", error); in adb_connect() local
218 if (fd == -2 && __adb_server_name) { in adb_connect()
220 return fd; in adb_connect()
221 } else if (fd == -2) { in adb_connect()
239 if (fd >= 0) { in adb_connect()
241 if (!ReadProtocolString(fd, &version_string, error)) { in adb_connect()
245 adb_close(fd); in adb_connect()
254 return fd; in adb_connect()
260 fd = _adb_connect("host:kill", error); in adb_connect()
261 adb_close(fd); in adb_connect()
274 fd = _adb_connect(service, error); in adb_connect()
275 if (fd == -1) { in adb_connect()
277 } else if(fd == -2) { in adb_connect()
280 D("adb_connect: return fd %d\n", fd); in adb_connect()
282 return fd; in adb_connect()
284 adb_close(fd); in adb_connect()
290 int fd = adb_connect(service, error); in adb_command() local
291 if (fd < 0) { in adb_command()
296 if (!adb_status(fd, error)) { in adb_command()
297 adb_close(fd); in adb_command()
306 int fd = adb_connect(service, error); in adb_query() local
307 if (fd < 0) { in adb_query()
313 if (!ReadProtocolString(fd, result, error)) { in adb_query()
314 adb_close(fd); in adb_query()