The accept
method does not actively participate in the handshake, per se. The sending and receiving of the messages is implemented in the TCP/IP protocol stack, typically in the OS kernel space.
However, the accept()
method is involved in the sense that the TCP/IP stack will only send the SYN-ACK message if some process has an accept()
call active for a socket bound with the relevant IP address and port. When the three-way handshake is completed, the accept()
method call will complete.
If no process calls accept()
in time the incoming SYN message will be dropped by the kernel and the remote client will eventually time out the connection attempt. (On the other hand, if the IP address / port is not bound, then the kernel is likely to respond with a RST, and the remote client will see a "connection refused".)