Home > Software engineering > The problem of win32 TCP communications straight to send and receive data
The problem of win32 TCP communications straight to send and receive data
Time:09-22
Encapsulates a mysocket class myself, using win32 API for socket, inside is TCP communications, the role of this class is as a client, even to the specified server, and then interact with the server data, according to the TCP client communication steps, it should have been send a lot of time after the call recv at a time, I think it is very trouble, just do it himself a thread, thread in an infinite loop, has been receiving data, the problem is that my next time send need to receive the last response data, and then according to the analytic results to determine what to send message, I tried in receiving the child thread with postThreadMessage to implement, but this time the main thread will be stuck here in getmessage, excuse me have a better way to solve this problem
CodePudding user response:
What this is involved in design patterns, I'm with the method of interface callback, the callback function onRecv, or provide a GetMessage traversal method receives the packet