Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to change a CSocket to use nonblocking mode?
Posted
Updated 31-Jan-12 15:41pm
v2

1 solution

For non-blocking calls you need to use CAsyncSocket instead. Blocking is explained here:
http://msdn.microsoft.com/en-us/library/3tbz7kf5%28v=vs.100%29.aspx[^].

I would advise to use CSocket and blocking calls with threads. Do all networking in separate threads. I think asynchronous APIs were offered when threads were not a commonplace and presently does not make a lot of sense. Threaded solutions are more straightforward, and the role of asynchronous callbacks, etc are played by thread communication primitives which are more explicit and give you more control.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900