DOKK / manpages / debian 11 / tcputils / getpeername.1.en
GETPEERNAME(1) General Commands Manual GETPEERNAME(1)

getpeername - get name of connected TCP/IP peer

getpeername [-n] [-p protocol]

getpeername prints the IP address and service name (port number) of the remote peer connected to standard input. The IP address and the service name are printed on the same line, separated by one space.

Don't translate IP addresses and port numbers to names.
Force getpeername to use protocol as the protocol when translating port numbers to service names. Protocol can be tcp and udp. Normally, getpeername automatically determines what type of socket it is connected to.

getpeername(3).

Only works on IP sockets.

1997 April 13