Understanding of the socket model

Source: Internet
Author: User
For a long time, socket programming has always been, rather than without a good concept. Today, I have taken a good look at some socket information and finally made some breakthroughs. I have some understanding of several socket functions.

In fact, all other functions are easy to say, that is, an accept function is hard to understand. Why is it so? Because accept is a blocking function, when the client's connect function connection is not received, the accept will not return. This is different from the general function. A general function returns immediately after the call, and there is no blocking problem.

The previous documents did not show that the white accept is a blocking function, but provided the connection mode between the client and the server of the five functions.

The socket returned by the accept function should be processed in a new process or thread. This avoids the receiving function of the main thread and focuses on data processing. As for the thread library, we recommend that you use the zthread library.

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.