Commit 5d9432b2 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #253 from ianbarber/master

Remove inet_ntop
parents 4b623440 2da76a30
......@@ -124,6 +124,7 @@ int zmq::tcp_listener_t::get_address (std::string *addr_)
{
struct sockaddr sa;
char host[INET6_ADDRSTRLEN];
char serv_info[32];
int port, rc;
std::stringstream portnum;
......@@ -136,14 +137,14 @@ int zmq::tcp_listener_t::get_address (std::string *addr_)
// Split the retrieval between IPv4 and v6 addresses
if ( sa.sa_family == AF_INET ) {
inet_ntop(AF_INET, &(((struct sockaddr_in *)&sa)->sin_addr), host, INET6_ADDRSTRLEN);
getnameinfo(&sa, sizeof(struct sockaddr), host, INET6_ADDRSTRLEN, serv_info, 32, NI_NUMERICHOST);
port = ntohs( ((struct sockaddr_in *)&sa)->sin_port);
portnum << port;
// Store the address for retrieval by users using wildcards
*addr_ = std::string("tcp://") + std::string(host) + std::string(":") + portnum.str();
} else {
inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)&sa)->sin6_addr), host, INET6_ADDRSTRLEN);
getnameinfo(&sa, sizeof(struct sockaddr), host, INET6_ADDRSTRLEN, serv_info, 32, NI_NUMERICHOST);
port = ntohs( ((struct sockaddr_in6 *)&sa)->sin6_port);
portnum << port;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment