I’m trying to understand how the events in a BSD socket interface translate to the state of a TCP Connection. In particular, I’m trying to understand at what stage in the connection process accept() returns on the server side
- client sends SYN
- server sends SYN+ACK
- client sends ACK
In which one of these steps does accept() return?
acceptreturns when the connection is complete. The connection is complete after the client sends his ACK.acceptgives you a socket on which you can communicate. Of course you know, you can’t communicate until the connection is established. And the connection can’t be established before the handshake.It wouldn’t make sense to return before the client sens his ACK. It is entirely possible he won’t say anything after the initial SYN.