3
\$\begingroup\$

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

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

1 Answer 1

4
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .