1. After the successful service listen, the system will automatically receive client requests.
Mans Listen:
There is a section of
The behavior of the backlog argument on TCP sockets changed with Linux
2.2. Now it specifies the queue length for completely established
Sockets waiting to be accepted, instead of the number of incomplete
Connection requests. The maximum length of the queue for incomplete
Sockets can be set Using/proc/sys/net/ipv4/tcp_max_syn_backlog. When
Syncookies are enabled there is no logical maximum length and this set‐
Ting is ignored. The "I" (7) for the more information.
In other words, listen successful, the system will automatically accept Bocklog client requests, does not require service-side accept, even if the server does not have accept, client connect still return success. Accept simply removes a socket from the backlog queue that has established a full TCP connection.
2. A FD socket connect, can not connect again
Connect again, will complain: transport endpoint is already connected
To connect again at this point, you must reset FD.
The state of the socket is set to ss_isconnected after the connection is established, so the error occurs before the call close resets the socket state.
The above is a small series for everyone to talk about the socket TCP programming connect some of the pits all content, I hope that we support cloud Habitat Community ~