I'm writing a multiple connection-server thingy .... And I'm wondering what the typical ways of communication between threads are.

Right now I'm using a WSAWaitForMultipleEvents and PeekMessage loop: the first waits for events on a socket, and the second looks for messages posted to the thread itself. I'm using a timer on the first, but I'm wondering if this is best way to do it. Opinions wanted: would it be smarter to create another eventobject for communication between threads, and then wait for either one to get signaled?

I was guessing that since this is probably a normal server issue, networking might be a good place to post it, even though it's not specifically networking related.

Fake
Posted on 2003-04-01 08:18:50 by Fake51
I would use events to communicate with other threads (like you suggested). I assume you're using WSAEventSelect so events fit nicely in the model of your thread. You could also combine the event and the message queue (ie signal the event to indicate arrival of a message), that's more efficient than a timeout.

Thomas
Posted on 2003-04-02 07:43:10 by Thomas
Yes, that's what I was thinking about, I just didn't bother creating another event for each thread, since I already had the thread id and could do a PostThreadMessage. But I guess I will change it now, seeing it will simplify my thread structure somewhat, and also make it more efficient.

Cheers
Fake
Posted on 2003-04-02 10:42:05 by Fake51
Posted on 2003-04-04 03:05:52 by IRBMe