PyDocs

Nav

Networking and Interprocess Communication

start_server

asyncio

async function (source) not WASI
  • start_server(client_connected_cb, host=None, port=None, *, limit=65536, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, keep_alive=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True)
Start a socket server, call back for each client connected.

The first parameter, `client_connected_cb`, takes two parameters:
client_reader, client_writer.  client_reader is a StreamReader
object, while client_writer is a StreamWriter object.  This
parameter can either be a plain callback function or a coroutine;
if it is a coroutine, it will be automatically converted into a
Task.

The rest of the arguments are all the usual arguments to
loop.create_server() except protocol_factory; most common are
positional host and port, with various optional keyword arguments
following.  The return value is the same as loop.create_server().

Additional optional keyword argument is limit (to set the buffer
limit passed to the StreamReader).

The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
Changed in 3.7, 3.10, 3.11, 3.13
  • 3.7: Added the ssl_handshake_timeout and start_serving parameters.
  • 3.10: Removed the loop parameter.
  • 3.11: Added the ssl_shutdown_timeout parameter.
  • 3.13: Added the keep_alive parameter.
0 Examples
No examples for asyncio/start_server.
See Also
No see-alsos for asyncio/start_server
0 Notes
No notes for start_server