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).

  • \$\begingroup\$ Do you mean on server? \$\endgroup\$ – kravemir Jun 30 '12 at 8:46
  • \$\begingroup\$ Wait, why not just have one port for the actual game? \$\endgroup\$ – jcora Jun 30 '12 at 17:21
  • \$\begingroup\$ @Miro, yes I'm asking about how many UDP ports to use on the server. \$\endgroup\$ – Xavier Jun 30 '12 at 23:56

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.