Talking about some pit _c language of connect in TCP programming of socket

Source: Internet
Author: User

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 ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.