Loading adb/sysdeps.h +1 −15 Original line number Diff line number Diff line Loading @@ -493,21 +493,7 @@ inline int network_local_server(const char* name, int namespace_id, int type, st return _fd_set_error_str(socket_local_server(name, namespace_id, type), error); } inline int network_connect(const std::string& host, int port, int type, int timeout, std::string* error) { int getaddrinfo_error = 0; int fd = socket_network_client_timeout(host.c_str(), port, type, timeout, &getaddrinfo_error); if (fd != -1) { return fd; } if (getaddrinfo_error != 0) { *error = gai_strerror(getaddrinfo_error); } else { *error = strerror(errno); } return -1; } int network_connect(const std::string& host, int port, int type, int timeout, std::string* error); static __inline__ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen) { Loading adb/sysdeps/posix/network.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -17,11 +17,15 @@ #include "sysdeps/network.h" #include <errno.h> #include <netdb.h> #include <netinet/in.h> #include <sys/socket.h> #include <string> #include <android-base/logging.h> #include <cutils/sockets.h> #include "adb_unique_fd.h" static void set_error(std::string* error) { Loading Loading @@ -124,3 +128,19 @@ int network_loopback_server(int port, int type, std::string* error) { } return rc; } int network_connect(const std::string& host, int port, int type, int timeout, std::string* error) { int getaddrinfo_error = 0; int fd = socket_network_client_timeout(host.c_str(), port, type, timeout, &getaddrinfo_error); if (fd != -1) { return fd; } if (getaddrinfo_error != 0) { *error = gai_strerror(getaddrinfo_error); LOG(WARNING) << "failed to resolve host '" << host << "': " << *error; } else { *error = strerror(errno); LOG(WARNING) << "failed to connect to '" << host << "': " << *error; } return -1; } adb/transport_local.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ std::tuple<unique_fd, int, std::string> tcp_connect(const std::string& address, std::string host; int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT; if (!android::base::ParseNetAddress(address, &host, &port, &serial, response)) { D("failed to parse address: '%s'", address.c_str()); return std::make_tuple(unique_fd(), port, serial); } Loading Loading @@ -103,6 +104,7 @@ void connect_device(const std::string& address, std::string* response) { return; } D("connection requested to '%s'", address.c_str()); unique_fd fd; int port; std::string serial; Loading Loading
adb/sysdeps.h +1 −15 Original line number Diff line number Diff line Loading @@ -493,21 +493,7 @@ inline int network_local_server(const char* name, int namespace_id, int type, st return _fd_set_error_str(socket_local_server(name, namespace_id, type), error); } inline int network_connect(const std::string& host, int port, int type, int timeout, std::string* error) { int getaddrinfo_error = 0; int fd = socket_network_client_timeout(host.c_str(), port, type, timeout, &getaddrinfo_error); if (fd != -1) { return fd; } if (getaddrinfo_error != 0) { *error = gai_strerror(getaddrinfo_error); } else { *error = strerror(errno); } return -1; } int network_connect(const std::string& host, int port, int type, int timeout, std::string* error); static __inline__ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen) { Loading
adb/sysdeps/posix/network.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -17,11 +17,15 @@ #include "sysdeps/network.h" #include <errno.h> #include <netdb.h> #include <netinet/in.h> #include <sys/socket.h> #include <string> #include <android-base/logging.h> #include <cutils/sockets.h> #include "adb_unique_fd.h" static void set_error(std::string* error) { Loading Loading @@ -124,3 +128,19 @@ int network_loopback_server(int port, int type, std::string* error) { } return rc; } int network_connect(const std::string& host, int port, int type, int timeout, std::string* error) { int getaddrinfo_error = 0; int fd = socket_network_client_timeout(host.c_str(), port, type, timeout, &getaddrinfo_error); if (fd != -1) { return fd; } if (getaddrinfo_error != 0) { *error = gai_strerror(getaddrinfo_error); LOG(WARNING) << "failed to resolve host '" << host << "': " << *error; } else { *error = strerror(errno); LOG(WARNING) << "failed to connect to '" << host << "': " << *error; } return -1; }
adb/transport_local.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ std::tuple<unique_fd, int, std::string> tcp_connect(const std::string& address, std::string host; int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT; if (!android::base::ParseNetAddress(address, &host, &port, &serial, response)) { D("failed to parse address: '%s'", address.c_str()); return std::make_tuple(unique_fd(), port, serial); } Loading Loading @@ -103,6 +104,7 @@ void connect_device(const std::string& address, std::string* response) { return; } D("connection requested to '%s'", address.c_str()); unique_fd fd; int port; std::string serial; Loading