asyncio.start_server()

coroutine asyncio.start_server(client_connected_cb, host=None, port=None, *, loop=None, limit=None, **kwds)

Start a socket server, with a callback for each client connected. The return value is the same as create_server().

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

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

Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader).

This function is a coroutine.

doc_python
2016-10-07 17:26:59
Comments
Leave a Comment

Please login to continue.