Blocking Input/Output
A version of this page is also available for
4/8/2010
The simplest form of I/O in Winsock is blocking I/O. As mentioned in section Socket Attribute Flags and Modes, sockets are created in blocking mode by default. Any I/O operation with a blocking socket will not return until the operation has been fully completed. Thus, any thread can only execute one I/O operation at a time. For example, if a thread issues a receive operation and no data is currently available, the thread will block until data becomes available and is placed into the thread's buffer. Although this is simple, it is not necessarily the most efficient way to do I/O in all Windows versions. In Win16 environments, for example, blocking is strongly discouraged due to the non-preemptive nature of the operating system.