Other servers use 1) i.e. listen from any client with one Socket (of which I assume there is one per UdpClient) . Furthermore:
- This one Socket should be used for the lifetime of the server, i.e. don't create a new one when done with one datagram.
- Receives and sends should be done asynchronously so receiving/sending one stream doesn't hold up receiving/sending another stream.
- Beware of the amount of data you send/receive - if you send/receive data to several clients from the server the total amount of data is multiplied by the amount of clients.
Doing the above on localhost with 50 clients sending ping and receiving a pong that is only a few bytes should take less than 1ms, assuming some other process is not maxing out the processors.