# HG changeset patch # User David Demelier # Date 1447947662 -3600 # Node ID b5b2bb02412a4c99854029b8fde99ab60e0c58c9 # Parent c03f84bdabe94a397556052e09a3dbee68ec155d Socket: add mutable because inet_ntop on Windows is not const diff -r c03f84bdabe9 -r b5b2bb02412a modules/sockets/sockets.h --- a/modules/sockets/sockets.h Wed Nov 18 14:31:22 2015 +0100 +++ b/modules/sockets/sockets.h Thu Nov 19 16:41:02 2015 +0100 @@ -1730,8 +1730,8 @@ static int m_default; union { - sockaddr_in m_sin; - sockaddr_in6 m_sin6; + mutable sockaddr_in m_sin; + mutable sockaddr_in6 m_sin6; }; socklen_t m_length{0}; @@ -1842,18 +1842,16 @@ */ std::string ip() const { - std::string result; + char result[128]; + + std::memset(result, 0, sizeof (result)); if (m_domain == AF_INET6) { - result.resize(INET_ADDRSTRLEN); - - if (!inet_ntop(AF_INET6, &m_sin6.sin6_addr, &result[0], INET_ADDRSTRLEN)) { + if (!inet_ntop(AF_INET6, &m_sin6.sin6_addr, result, sizeof (result))) { throw Error{Error::System, "inet_ntop"}; } } else { - result.resize(INET6_ADDRSTRLEN); - - if (!inet_ntop(AF_INET, &m_sin.sin_addr, &result[0], INET6_ADDRSTRLEN)) { + if (!inet_ntop(AF_INET, &m_sin.sin_addr, result, sizeof (result))) { throw Error{Error::System, "inet_ntop"}; } }