MCPcopy Create free account
hub / github.com/apache/brpc / get_remote_side

Function get_remote_side

src/butil/endpoint.cpp:605–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603}
604
605int get_remote_side(int fd, EndPoint *out) {
606 struct sockaddr_storage addr;
607 bzero(&addr, sizeof(addr));
608 socklen_t socklen = sizeof(addr);
609 const int rc = getpeername(fd, (struct sockaddr*)&addr, &socklen);
610 if (rc != 0) {
611 return rc;
612 }
613 if (out) {
614 return sockaddr2endpoint(&addr, socklen, out);
615 }
616 return 0;
617}
618
619int endpoint2sockaddr(const EndPoint& point, struct sockaddr_storage* ss, socklen_t* size) {
620 bzero(ss, sizeof(*ss));

Callers 2

test_listen_connectFunction · 0.85
ResetFileDescriptorMethod · 0.85

Calls 1

sockaddr2endpointFunction · 0.85

Tested by 1

test_listen_connectFunction · 0.68