Fixed issue #17.
This commit is contained in:
parent
941159b3ac
commit
3ac625efa5
@ -189,10 +189,15 @@ const string windowsSocket::getPeerAddress() const
|
|||||||
getpeername(m_desc, reinterpret_cast <sockaddr*>(&peer), &peerLen);
|
getpeername(m_desc, reinterpret_cast <sockaddr*>(&peer), &peerLen);
|
||||||
|
|
||||||
// Convert to numerical presentation format
|
// Convert to numerical presentation format
|
||||||
char numericAddress[1024];
|
char host[NI_MAXHOST + 1];
|
||||||
|
char service[NI_MAXSERV + 1];
|
||||||
|
|
||||||
if (inet_ntop(peer.sa_family, &peer, numericAddress, sizeof(numericAddress)) != NULL)
|
if (getnameinfo(reinterpret_cast <sockaddr *>(&peer), peerLen,
|
||||||
return string(numericAddress);
|
host, sizeof(host), service, sizeof(service),
|
||||||
|
/* flags */ NI_NUMERICHOST) == 0)
|
||||||
|
{
|
||||||
|
return string(host);
|
||||||
|
}
|
||||||
|
|
||||||
return ""; // should not happen
|
return ""; // should not happen
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user