Search code examples
c++socketsclient-serverwinsockports

C++ Sockets - Multiple Ports or single ports


I'm not about to jump into trying to make a game or anything, but I remember something that came up in the past, and I wanted to see what stackoverflow thinks about it.

A while back, me and a friend had played a game called starcraft both through the same router. When we tried to play together in multiplayer games, it was very laggy, to the point where it was unplayable. I couldn't figure out why it was, since the game was from the 90s and the fact that my internet could definitely handle much more than the game required.

I did some research, and I found someone talking about the reason that the game was running so slow when two people from the same router tried to play together on the main server. They said that the reason for this was because of the fact that the game only uses ports 6112. They said that the router is limited on how much it can send on one port at a time, so since both computers were using port 6112, it was in a sense bottlenecking.

So here is my question.

For someone who is going to develop a server/client application, would it make more sense to have the client connect to the server on an initial port, receive a new port to connect on, disconnect, and reconnect on a new port to have as many ports being used as possible? Or would this not make a difference?

Summary: Is it more efficient to use multiple ports on a server/client application where there is more than one client, or is it more efficient to run all of the data through one port?

Thanks for taking the time to read.


Solution

  • They said that the reason for this was because of the fact that the game only uses ports 6112. They said that the router is limited on how much it can send on one port at a time, so since both computers were using port 6112, it was in a sense bottlenecking.

    They didn't know what they were talking about. There is no such limitation. There is no reason for you to use more than one port. The connect/reconnect scenario you outline only adds network overhead and accomplishes nothing useful.