As I understand it this is what happens when a client makes a connection request:
- The server will be bound to a particular port number. The port number is always bound to a listening process. Since only the server is listening for incoming connections, we don't need to bind on the client side
- The server will keep on listeninig on that port number.
- The client will send a
- The server will accept the request using
accept(). As soon as the server accepts the client request, the kernel allocates a random port number for the server for further
receive(), since the same port number on the server can't be used for sending as well as listening, and the previous port is still listening for new connections
Given all that, how does the server find out what port the client is receiving on? I know the client will send TCP segments with a source port and destination port, so the server will use the source port of that segment as its destination port, but what function does the server call to find out about that port? Is it