Recently an integrated project debugging communication interface, in order to make full use of multi-core CPU, understanding learning IOCP model - learn a little experience, not comprehensive network monitoring is to perfect the implementation, the client, a TCP connection, a serial port, HID, UDP client, named pipes and its implementation, version 1.0 debugging good, are not satisfied, disconnects processing aspects of the problems, explore the author here: Such as TCP connection, the server-side call DISCONNECTEX, if the client does not call corresponding DISCONNECTEX or closesocket - such as a third party to do the client, the server doesn't receive feedback, version 1.0, the server-side closesocket directly, can have the function of disconnected, but can't reuse a socket, 2. If the server and the client are have DISCONNECTEX function, design thought if the received data length is 0, then DISCONNECTEX, this connection can be completely cut off of the "elegant" but shall only be DISCONNECTEX first, SEND the recipient receives data length is 0, then also DISCONNECTEX, the sender received feedback, disconnect the connection grace,
Now have the following questions 1. The server-side implementation socket reuse have how old? I do is the Internet of things has around 1000 users online at the same time, also can constantly disconnect reconnection - 2 g network is not stable, the server needs to solve real-time close illegal connection, maximum efficiency of concurrent... 2. 2 in front of the train of thought practice effectively, whether it is right, is there any way to solve the client sends, the server receives, the server can DISCONNECTEX and disconnected; Heartbeat mode, the server should receive terminal data, and to send a heartbeat packet (right?) After, take the initiative to DISCONNECT the client response disconnected, is everything OK, you did this?
CodePudding user response:
The server socket how to implement? I understand that the socket is broken again, it is not a value, and the socket is an unsigned integer, there is no create time-consuming problem, Server-side IOCP application should always deliver recv request, once the client disconnects should activate the callback function and the received data for 0. Do not know the client do not call closesocket will, so forget,
CodePudding user response:
1000 users online at the same time The select IO model will do the trick,