I’m working on a server in c++ that will connect to a multitude of clients via UDP. I’ve decided that a thread pool would be best to handle incoming datagrams from a given socket.
My question is, then, would it be best in terms of scalability to allow each worker thread to make a call to sendto? Should they do so on the same socket or would a different one be preferable? All the traffic will go through a single port.
From what I’ve ready, it seems that the calls to recvfrom and sendto are atomic and I already have a dedicated thread to listen to the socket (currently nonblocking and uses calls to select to figure out whether a socket is ready to be read from).
If I were to go on my own accord, I would probably utilize a different socket to send and use multiple threads to do so (assuming all actions were valid).
Not sure how helpful this will be, but this is the general idea:

There is no advantage to using multiple UDP sockets for multiple threads so as long they are non-blocking, and using a single bound UDP socket better maps to your stated requirements. That’s part of the fun of implementing stateless, datagram-oriented protocols.
Does this address/confirm your question(s)?