diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/platforms/windows/windowsSocket.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/platforms/windows/windowsSocket.cpp b/src/platforms/windows/windowsSocket.cpp index 72c5f0f6..13de81ee 100644 --- a/src/platforms/windows/windowsSocket.cpp +++ b/src/platforms/windows/windowsSocket.cpp @@ -189,10 +189,15 @@ const string windowsSocket::getPeerAddress() const getpeername(m_desc, reinterpret_cast <sockaddr*>(&peer), &peerLen); // 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) - return string(numericAddress); + if (getnameinfo(reinterpret_cast <sockaddr *>(&peer), peerLen, + host, sizeof(host), service, sizeof(service), + /* flags */ NI_NUMERICHOST) == 0) + { + return string(host); + } return ""; // should not happen } |