I'm designing an MMOFPS. I'm not sure whether to use one UDP port for all clients or one UDP port per client. Or is there another alternative?
Currently UDP is only being used for position data (X,Y,Z, heading, and pitch).
I'm designing an MMOFPS. I'm not sure whether to use one UDP port for all clients or one UDP port per client. Or is there another alternative?
Currently UDP is only being used for position data (X,Y,Z, heading, and pitch).
Having one UDP port per client seems complicated an inefficent. The client would need to start by sending a open-port-request so the server opens a new port for that client. Also, the performance for checking ports for available data might degrade with the number of sockets.
As long as the received datagram is handled quickly so the thread can continue receiving new data I don't think you'll have a bottleneck here. A solution would be to have one thread receiving UDP datagrams and just putting them on a queue. Use a pool of worker threads that pop data from queue and perform the actual work. The number of worker threads could be chosen to match the number of cores available on the machine.