Question : Cancel blocking socket operation in WinSock 2.0

For some reason, I use blocking socket in my program. Each of my working thread receive UDP data package from a certain port. During the application running, everyting is ok. But when I need to exit the program and tell all the working thread to shut down, the problem occurs. I can't use closesock(...) directly (from other thread), because if I do like this, it will also block (WSARecvFrom(...) is still waiting for the next package). After checking MSDN, I found a WinSock API WSACancelBlockingCall(), but it is only supported by WinSock 1.1. Now my temporary solution is terminate the waiting thread directly, then close the socket. But I feel it not so good, have you a better solution?
Thanks.

Answer : Cancel blocking socket operation in WinSock 2.0

Admin notified of user neglect. Points refunded and question closed.

Netminder
Community Support Moderator
Experts Exchange
Random Solutions  
 
programming4us programming4us