Blocking in a thread?
Is it okay to do a blocking call to a receive function if your network code is in another thread? Or are there some kind of consequences to that?
-=Lohrno
If you have several socket and your network thread is blocked waiting for data from one of them, it will not process the other sockets, even though they may have data and would not block.
One solution is to have your thread block on select() instead : select returns once at least one of the sockets in the set you give it can be read/written to.
One solution is to have your thread block on select() instead : select returns once at least one of the sockets in the set you give it can be read/written to.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement