@@ -9,8 +9,6 @@ using node::MallocedBuffer;
99void ReportEndpoints (uv_handle_t * h, std::ostringstream& out) {
1010 struct sockaddr_storage addr_storage;
1111 struct sockaddr * addr = reinterpret_cast <sockaddr*>(&addr_storage);
12- char hostbuf[NI_MAXHOST];
13- char portbuf[NI_MAXSERV];
1412 uv_any_handle* handle = reinterpret_cast <uv_any_handle*>(h);
1513 int addr_size = sizeof (addr_storage);
1614 int rc = -1 ;
@@ -26,33 +24,22 @@ void ReportEndpoints(uv_handle_t* h, std::ostringstream& out) {
2624 break ;
2725 }
2826 if (rc == 0 ) {
29- // getnameinfo will format host and port and handle IPv4/IPv6.
30- rc = getnameinfo (addr,
31- addr_size,
32- hostbuf,
33- sizeof (hostbuf),
34- portbuf,
35- sizeof (portbuf),
36- NI_NUMERICSERV);
37- if (rc == 0 ) {
38- out << std::string (hostbuf) << " :" << std::string (portbuf);
39- }
27+ // uv_getnameinfo will format host and port and handle IPv4/IPv6.
28+ uv_getnameinfo_t local;
29+ rc = uv_getnameinfo (h->loop , &local, nullptr , addr, NI_NUMERICSERV);
30+
31+ if (rc == 0 )
32+ out << local.host << " :" << local.service ;
4033
4134 if (h->type == UV_TCP) {
4235 // Get the remote end of the connection.
4336 rc = uv_tcp_getpeername (&(handle->tcp ), addr, &addr_size);
4437 if (rc == 0 ) {
45- rc = getnameinfo (addr,
46- addr_size,
47- hostbuf,
48- sizeof (hostbuf),
49- portbuf,
50- sizeof (portbuf),
51- NI_NUMERICSERV);
52- if (rc == 0 ) {
53- out << " connected to " ;
54- out << std::string (hostbuf) << " :" << std::string (portbuf);
55- }
38+ uv_getnameinfo_t remote;
39+ rc = uv_getnameinfo (h->loop , &remote, nullptr , addr, NI_NUMERICSERV);
40+
41+ if (rc == 0 )
42+ out << " connected to " << remote.host << " :" << remote.service ;
5643 } else if (rc == UV_ENOTCONN) {
5744 out << " (not connected)" ;
5845 }
0 commit comments