PyDocs

Nav

Networking and Interprocess Communication

create_server

socket

function · Added in 3.8 (source) not WASI
  • create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, dualstack_ipv6=False)
Convenience function which creates a SOCK_STREAM type socket
bound to *address* (a 2-tuple (host, port)) and return the socket
object.

*family* should be either AF_INET or AF_INET6.
*backlog* is the queue size passed to socket.listen().
*reuse_port* dictates whether to use the SO_REUSEPORT socket option.
*dualstack_ipv6*: if true and the platform supports it, it will
create an AF_INET6 socket able to accept both IPv4 or IPv6
connections. When false it will explicitly disable this option on
platforms that enable it by default (e.g. Linux).

>>> with create_server(('', 8000)) as server:
...     while True:
...         conn, addr = server.accept()
...         # handle new connection
0 Examples
No examples for socket/create_server.
See Also
No see-alsos for socket/create_server
0 Notes
No notes for create_server