Index: runtime/bin/socket_linux.cc |
diff --git a/runtime/bin/socket_linux.cc b/runtime/bin/socket_linux.cc |
index 361e2259bb56a5e6d1ce98c08fe5bc6f27cf2d20..5f4096bb75f3120625ccbc2bb3fb705f70fdeeee 100644 |
--- a/runtime/bin/socket_linux.cc |
+++ b/runtime/bin/socket_linux.cc |
@@ -95,13 +95,23 @@ intptr_t Socket::GetPort(intptr_t fd) { |
getsockname(fd, |
reinterpret_cast<struct sockaddr *>(&socket_address), |
&size))) { |
- fprintf(stderr, "Error getsockname: %s\n", strerror(errno)); |
return 0; |
} |
return ntohs(socket_address.sin_port); |
} |
+void Socket::GetError(intptr_t fd, OSError* os_error) { |
+ int len = sizeof(errno); |
+ getsockopt(fd, |
+ SOL_SOCKET, |
+ SO_ERROR, |
+ &errno, |
+ reinterpret_cast<socklen_t*>(&len)); |
+ os_error->SetCodeAndMessage(OSError::kSystem, errno); |
+} |
+ |
+ |
intptr_t Socket::GetStdioHandle(int num) { |
return static_cast<intptr_t>(num); |
} |
@@ -121,8 +131,6 @@ const char* Socket::LookupIPv4Address(char* host, OSError** os_error) { |
*os_error = new OSError(status, |
gai_strerror(status), |
OSError::kGetAddressInfo); |
- (*os_error)->set_code(status); |
- (*os_error)->SetMessage(gai_strerror(status)); |
return NULL; |
} |
// Convert the address into IPv4 dotted decimal notation. |