diff options
author | Vincent Richard <[email protected]> | 2012-12-27 20:14:09 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2012-12-27 20:14:24 +0000 |
commit | 3ac625efa58d1f60f238b74cb0596e67ff382648 (patch) | |
tree | 61471ec6070b0b95e99af4052ec5d64a478ae942 /src/platforms/windows/windowsSocket.cpp | |
parent | Merge pull request #16 from mabrand/master-fix-example (diff) | |
download | vmime-3ac625efa58d1f60f238b74cb0596e67ff382648.tar.gz vmime-3ac625efa58d1f60f238b74cb0596e67ff382648.zip |
Fixed issue #17.
Diffstat (limited to 'src/platforms/windows/windowsSocket.cpp')
-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 } |