non_blocking


Description:

[ NoAccessorMethod ]
public bool non_blocking { get; set; }

Whether or not the socket uses non-blocking I/O.

Socket's I/O methods are designed around the idea of using a single codepath for both synchronous and asynchronous I/O. If you want to read off a Socket, the "correct" way to do it is to call read or read_until repeatedly until you have read everything you want. If it returns WOULD_BLOCK at any point, stop reading and wait for it to emit the readable signal. Then go back to the reading-as-much-as-you-can loop. Likewise, for writing to a Socket, you should call write either until you have written everything, or it returns WOULD_BLOCK (in which case you wait for writable and then go back into the loop).

Code written this way will work correctly with both blocking and non-blocking sockets; blocking sockets will simply never return WOULD_BLOCK, and so the code that handles that case just won't get used for them.