* Returns the peer's `Address` for the accepted or connected socket. * * @return An `Address` or an error if the `getpeername` system call * fails or the family type is not supported. */
| 96 | * fails or the family type is not supported. |
| 97 | */ |
| 98 | inline Try<Address> peer(int_fd s) |
| 99 | { |
| 100 | sockaddr_storage storage; |
| 101 | socklen_t length = sizeof(storage); |
| 102 | |
| 103 | if (::getpeername(s, (sockaddr*)&storage, &length) < 0) { |
| 104 | return ErrnoError("Failed to getpeername"); |
| 105 | } |
| 106 | |
| 107 | return Address::create(storage); |
| 108 | } |
| 109 | |
| 110 | } // namespace network { |
| 111 | } // namespace process { |
no outgoing calls
no test coverage detected