From a996db6600acb5af0f0ec65ec9e320ec7d807ef7 Mon Sep 17 00:00:00 2001 From: crs Date: Fri, 21 Jun 2002 16:29:35 +0000 Subject: [PATCH] now trying to convert hostname as a dot notation address before trying name lookup. not all platforms will do this for us in gethostbyname(). --- net/CNetworkAddress.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/CNetworkAddress.cpp b/net/CNetworkAddress.cpp index debd9d32..726e4392 100644 --- a/net/CNetworkAddress.cpp +++ b/net/CNetworkAddress.cpp @@ -99,6 +99,18 @@ CNetworkAddress::CNetworkAddress(const CString& hostname_, UInt16 port) : return; } + // convert dot notation to address + unsigned long addr = CNetwork::inet_addr(hostname.c_str()); + if (addr != INADDR_NONE) { + struct sockaddr_in* inetAddress = reinterpret_cast< + struct sockaddr_in*>(&m_address); + inetAddress->sin_family = AF_INET; + inetAddress->sin_port = CNetwork::swaphtons(port); + inetAddress->sin_addr.s_addr = addr; + memset(inetAddress->sin_zero, 0, sizeof(inetAddress->sin_zero)); + return; + } + // look up name struct hostent* hent = CNetwork::gethostbyname(hostname.c_str()); if (hent == NULL) {