The accept method does not take an active part in the handshake. Messages are sent and received on the TCP / IP protocol stack, usually in the kernel space of the OS.
However, the accept() method is involved in the sense that the TCP / IP stack only sends a SYN-ACK message if any process has an accept() call active for the socket associated with the corresponding IP address and port. When the three-way handshake is completed, the call to the accept() method ends.
If no process calls accept() over time, the incoming SYN message will be discarded by the kernel and the remote client will eventually disconnect the connection attempt. (On the other hand, if the IP address / port is not mapped, the kernel will most likely respond with RST, and the remote client will see “connection refused”.)
source share