-
December 4th, 2012, 04:13 PM
#1
winsock application and multhreading - listening to socket event from another thread
assume I have an application which uses winsock to implement tcp communication. for each socket we create a thread and block-receiving on it. when data arrives, we would like to
notify other threads (listening threads).
i was wondering what is the best way to implement this:
1. move away from this design and use a non-blocking socket, then the listening thread will have to iterate constantly and call a non-blocking receive,
thus making it thread safe (no extra threads for the sockets)
2. use asynchronous procedure calls to notify listening threads - which again will have to alert-wait for apc to queue for them.
3. implement some thread safe message queue, where each socket thread will post messages to it, and the listener, again, will go over it every interval and pull data from it.
also, i read about WSAAsyncSelect, but i saw that this is used to send messages to a window. isnt there something similar for other threads? (well i guess apcs are...)
Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|