How many times is connection_made called for asyncio's create_datagram_endpoint?

Viewed 35

Python's asyncio examples show how to create a 'protocol class' for a TCP echo server. The example seems to indicate that these objects spawn for each client connection. In which case: connection_made fires for each new client connection and a 'transport' instance encapsulates a TCP stream socket for the new client.

https://docs.python.org/3/library/asyncio-protocol.html#tcp-echo-server

My question is: to what extent does this behaviour still apply to UDP servers?

My interpretation of the UDP echo server example is that:

  1. There's one UDP listen socket.
  2. UDP is not connection-orientated so there is no need for individual client sockets to be spawned. The same socket is reused for all clients.
  3. Therefore, 'connection_made' would not fire per client. It would fire once, after the server was started.
  4. In which case: this is quite a lot different to how the TCP echo server works since a new object isn't created per client.

https://docs.python.org/3/library/asyncio-protocol.html#udp-echo-server

Is this correct, or am I missing something?

0 Answers
Related