ID EN
Socket

getsockname

Python 3.11

Return the socket’s own address. This is useful to find out the port number of an IPv4/v6 socket, for instance. (The format of the address returned depends on the address family — see above.)

Syntax

PYTHON
socket.getsockname()