diff --git a/util/sock.h b/util/sock.h index 4a2a3194b40..ba7b6200172 100644 --- a/util/sock.h +++ b/util/sock.h @@ -220,11 +220,12 @@ namespace mongo { addressSize = sizeof(sa); } - inline SockAddr::SockAddr(const char *ip, int port) { + inline SockAddr::SockAddr(const char * iporhost , int port) { + string ip = hostbyname( iporhost ); memset(sa.sin_zero, 0, sizeof(sa.sin_zero)); sa.sin_family = AF_INET; sa.sin_port = htons(port); - sa.sin_addr.s_addr = inet_addr(ip); + sa.sin_addr.s_addr = inet_addr(ip.c_str()); addressSize = sizeof(sa); }