Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10600)

Unified Diff: chrome/test/chromedriver/net/adb_client_socket.cc

Issue 2349423003: Fallback to IPv6 if IPv4 adb port not available. (Closed)
Patch Set: Fallback to IPv6 if IPv4 adb port not available. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/net/adb_client_socket.cc
diff --git a/chrome/test/chromedriver/net/adb_client_socket.cc b/chrome/test/chromedriver/net/adb_client_socket.cc
index 9a5a672c6bc7e69fc06f35237c67cd837b01f100..7938ceabe7f049daf26689d3a654e6b7249cc265 100644
--- a/chrome/test/chromedriver/net/adb_client_socket.cc
+++ b/chrome/test/chromedriver/net/adb_client_socket.cc
@@ -365,8 +365,16 @@ AdbClientSocket::~AdbClientSocket() {
}
void AdbClientSocket::Connect(const net::CompletionCallback& callback) {
- net::AddressList address_list = net::AddressList::CreateFromIPAddress(
- net::IPAddress::IPv4Localhost(), port_);
+ // In a IPv4/IPv6 dual stack environment, getaddrinfo for localhost could
+ // only return IPv6 address while current adb (1.0.36) will always listen
+ // on IPv4. So just try IPv4 first, then fall back to IPv6.
+ net::IPAddressList list = {net::IPAddress::IPv4Localhost(),
+ net::IPAddress::IPv6Localhost()};
+ net::AddressList ip_list = net::AddressList::CreateFromIPAddressList(
+ list, "localhost");
+ net::AddressList address_list = net::AddressList::CopyWithPort(
+ ip_list, port_);
+
socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL,
net::NetLog::Source()));
int result = socket_->Connect(callback);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698