CAsyncSocket and Multithreading
Posted on 2003-03-04
I have a small problem. In my server application I accept the connecting clients when OnAccept is called from the main thread on my server socket. I then create the client socket and put it into a list where they are globally accessed by calling threads. Meaning that Send() on the socket might be called from any thread in the application. This doesn’t’ sound good but it seem to work until now.
I have started to experience problems, the send() function is sometimes returning WSAEWOULDBLOCK which never goes away on some client sockets. Might this have anything to do with me calling the Send() function from different threads?
What is the correct way to handle WSAEWOULDBLOCK? Is it to queue the data and wait for a OnSend() ?
Any special fall pits I should have in mind when working with multithreaded applications and CAsynSocket?