How tcp/ip client server listening sockets work...

I know that in the client server pardigm of tcpip-based sockets, the server app listens at a specific IP address and port number....

The server app then spawns? a connection such that any subsequent socket communication between the client and the server is done via another port number? My understnading is that this is necessary so as to enable the server to keep listening on the listening port and to be able to handle multiple requests....

In terms of enabling this communication when using a firewall, do port numbers other than the one being used as a listening socket need to be freed up to permit the "after the listen socket answers the call" connection establishment to take place?

Who is Participating?
grbladesConnect With a Mentor Commented:
Therefore as far as the firewall is concerned you just permit traffic to the servers port (port 80 for standard web traffic for example).
There are a few awkward protocols such as FTP where a separate connection is used to transfer the data so the firewall needs to open these up aswell. Most firewalls inspect the commands issued on a FTP connection to see what ports are going to be used for the data connection and automatically open these for that single session.
Yes the server app does usually spawn or at least there is a new thread started within the main process in order for the software to be able to handle multiple simultaneous connections.

However the port number does not change. When the client makes a connection to a server it does so from its IP address and a high numbered port (1024 - 65535) and it is the operating system at the servers end which keeps record of all the open connections and passes the data from the client to the correct server process bases upon the source IP address and port.
rsivanandanConnect With a Mentor Commented:
Good idea to go through this video hands-on; simple + small + good

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.