one very basic question. I am starting in this field and the answer will clarify many things. Is it possible for a server to hold several client connections sharing the same port? (meaning the client socket, not the listening socket (serversocket)).
I have done some practice with some code pieces from the internet, and have seen that each time a new client connects, a new port number is assigned. I figure to think that the server might be bound to a concrete number of connections derived from its port capacity. So, then it arises the question, is it possible to use several connections in the same port number?.
At the beginning I thought Nooo.... , BUT since TCP ensures completion and that packages are received in the right order, perhaps I can build a logic in my program that allows me to separate packages corresponding to each connection.
On the other hand, if possible, how can I decide the port being shared. The serverSocket accepts the connection and creates a socket automatically without having the chance to specify a port number.
Many thanks in advance. Any help is greatly appreciated.
Since it's a basic question, can I ask another basic question in return? Here it is: why do you want to know? You can certainly have multiple clients connected to the same server; they all use the same server socket but they all use different client sockets. This works perfectly well in practice, so it's not obvious why you want to interfere with the process.
Joined: Apr 21, 2010
Thanks Paul for your quick answer,
I don't think I ever need to implement such a solution, and probably is out of my scope right now.
However in case an application hosted in a server received huges amount of requests, in order to be able to attend them a different approach should be adopted isn't it?. I am not aware right now which amount of simultaneous connections can a regular server attend, but I guess other server architechtures are more suitable when such situations arise...
This is more a question for my knowledge rather than something I must do in real life.