| Index: runtime/bin/socket_macos.cc
|
| diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
|
| index 0e4acd0f85076fc025370dc94d477167233c9dd6..5d5cce86c288d403f3533f7006a4c42ac62f926c 100644
|
| --- a/runtime/bin/socket_macos.cc
|
| +++ b/runtime/bin/socket_macos.cc
|
| @@ -107,6 +107,40 @@ intptr_t Socket::GetStdioHandle(int num) {
|
| }
|
|
|
|
|
| +const char* Socket::LookupIPv4Address(char* host, OSError** os_error) {
|
| + // Perform a name lookup for an IPv4 address.
|
| + struct addrinfo hints;
|
| + memset(&hints, 0, sizeof(hints));
|
| + hints.ai_family = AF_INET;
|
| + hints.ai_socktype = SOCK_STREAM;
|
| + hints.ai_protocol = IPPROTO_TCP;
|
| + struct addrinfo* info = NULL;
|
| + int status = getaddrinfo(host, 0, &hints, &info);
|
| + if (status != 0) {
|
| + ASSERT(*os_error == NULL);
|
| + *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.
|
| + char* buffer = reinterpret_cast<char*>(malloc(INET_ADDRSTRLEN));
|
| + sockaddr_in *sockaddr = reinterpret_cast<sockaddr_in *>(info->ai_addr);
|
| + const char* result = inet_ntop(AF_INET,
|
| + reinterpret_cast<void *>(&sockaddr->sin_addr),
|
| + buffer,
|
| + INET_ADDRSTRLEN);
|
| + if (result == NULL) {
|
| + free(buffer);
|
| + return NULL;
|
| + }
|
| + ASSERT(result == buffer);
|
| + return buffer;
|
| +}
|
| +
|
| +
|
| intptr_t ServerSocket::CreateBindListen(const char* host,
|
| intptr_t port,
|
| intptr_t backlog) {
|
|
|