mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-22 18:28:39 +01:00
commit
5d9432b282
@ -124,6 +124,7 @@ int zmq::tcp_listener_t::get_address (std::string *addr_)
|
|||||||
{
|
{
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
char host[INET6_ADDRSTRLEN];
|
char host[INET6_ADDRSTRLEN];
|
||||||
|
char serv_info[32];
|
||||||
int port, rc;
|
int port, rc;
|
||||||
std::stringstream portnum;
|
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
|
// Split the retrieval between IPv4 and v6 addresses
|
||||||
if ( sa.sa_family == AF_INET ) {
|
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);
|
port = ntohs( ((struct sockaddr_in *)&sa)->sin_port);
|
||||||
portnum << port;
|
portnum << port;
|
||||||
|
|
||||||
// Store the address for retrieval by users using wildcards
|
// Store the address for retrieval by users using wildcards
|
||||||
*addr_ = std::string("tcp://") + std::string(host) + std::string(":") + portnum.str();
|
*addr_ = std::string("tcp://") + std::string(host) + std::string(":") + portnum.str();
|
||||||
} else {
|
} 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);
|
port = ntohs( ((struct sockaddr_in6 *)&sa)->sin6_port);
|
||||||
portnum << port;
|
portnum << port;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user