Hi !

I feel a little dumb, as I am trying to understand something which seems evident to everyone, and so that I cannot find a clear answer. I hope you guys could enlight my questions:

I am trying to figure out how can a server handle multiple entrant connections. For instance, how work a Database Server to accept parallel requests and answer them, with sometimes big data, while only 1 port is available for this.

I imagine my 'SELECT' request arriving to the port 1234 of my DB server. This would lock the port 1234 to my connection, until (I guess) the server has something to answer. Once it has answered, the port would be once again free to serve a new request.
If so, I cannot understand how the service can be done, if I am dumping tables for 1 hour... this doesn't block the other connection !?!

What about a Game Server, for instance. You start a game, I connect to the server 1234, maybe temporarly, time to give indication of the game and exit. How can the server serve multiple connections on only 1 port !?!!

It sounds impossible, and I really feel I am missing something very big.. Please be not to hard with me :)))


1 Month
Discussion Span
Last Post by rubberman

You can use select() with multiple file descriptors. You should also set a timeout value which is one of the arguments to select(). You need to more reading on this. It is very basic TCP/IP programming.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.