now trying to convert hostname as a dot notation address before

trying name lookup.  not all platforms will do this for us in
gethostbyname().
This commit is contained in:
crs 2002-06-21 16:29:35 +00:00
parent 327af03d3d
commit a996db6600

View File

@ -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) {