Reputation:
We know that there are two sockets, welcoming socket and connection socket as picture below shows:
So welcoming socket ise used to initiate TCP three-way handshake while connection socket is actually used for data transmission betweet client and server.
And below is a picture depicts the process of TCP three-way handshake:
This third stage of the three-way handshake may carry client-to-server data in the segment payload.
so my question is, which socket is used to send the third stage segment? I think it should be connection socket becuase the segment can contain data and connection socket is used to transmit data, but since the third stage is part of three-way handshake process, the welcoming socket should be used?
Upvotes: 0
Views: 496
Reputation: 123320
A socket is not a real thing but an abstraction for the programmer, i.e. an API. It is not relevant which socket "does" the TCP handshake or if there is even something like a socket in the OS kernel doing the TCP handshake.
What matters is that accept
always returns a connected socket, i.e. the TCP handshake is done at this point. The listening socket instead stays unconnected so that it can accept new clients.
Upvotes: 1