mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-27 10:38:48 +03:00
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:
parent
327af03d3d
commit
a996db6600
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user