ID EN
Socket

getpeername

Python 3.11

Return the remote address to which the socket is connected. This is useful to find out the port number of a remote IPv4/v6 socket, for instance. (The format of the address returned depends on the address family — see above.) On some systems this function is not supported.

Syntax

PYTHON
socket.getpeername()