Asynchronous multi-direction server-client communication over the same open socket? | I have a client-server app where the client is on a Windows Mobile 6 device, written in C++ and the server is on full Windows and written in C#.


Originally, I only needed it to send messages from the client to the server, with the server only ever sending back an acknowledgment that it received the message. Now, I would like to update it so that the server can actually send a message to the client to request data. As I currently have it set up so the client is only in receive mode after it sends data to the server, this doesn't allow for the server to send a request at any time. I would have to wait for client data. My first thought would be to create another thread on the client with a separate open socket, listening for server requests...just like the server already has with respect to the client. Is there a way, within the same thread and using the same socket, for all the servers to send requests at any time?


Can you use something to the effect of `WaitForMultipleObjects()` and pass it a receive buffer and an event that tells it there is data to be sent?