PyDocs

Nav

Development Tools

find_unused_port

  • find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM)
Returns an unused port that should be suitable for binding. This is achieved by creating a temporary socket with the same family and type as the sock parameter (default is AF_INET, SOCK_STREAM), and binding it to the specified host address (defaults to 0.0.0.0) with the port set to 0, eliciting an unused ephemeral port from the OS. The temporary socket is then closed and deleted, and the ephemeral port is returned.
0 Examples
No examples for test.support.socket_helper/find_unused_port.
See Also
No see-alsos for test.support.socket_helper/find_unused_port
0 Notes
No notes for find_unused_port