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.