I'm creating a TCP client using C++ and Winsock. I created a message-only window which will process the WM_SOCKET message, which I registered using WSAAsyncSelect.
My question is the following: I need to send data from another thread (the GUI thread of my app), can I safely call the 'send' function from that thread or maybe do I need to use some locking interface (mutexes) in order to send data?
There should be no problem sending from a different thread from the one that receives.
For datagram sockets, you can even have multiple threads sending at once (messages will be interleaved but not intermingled).
For stream sockets, which includes TCP, multiple simultaneous senders could intermingle data, so only one sending thread at a time is recommended. But even with a one sending thread limit, it doesn't have to be the same as the receiving thread.