Sachin Chourasiya Sachin Chourasiya - 9 months ago 77
C Question

How do I change a TCP socket to be non-blocking?

How do you make a socket non-blocking?

I am aware of the

function, but I've heard it's not always reliable.

Answer Source

What do you mean by "not always reliable"? If the system succeeds in setting your socket non non-blocking, it will be non-blocking. Socket operations will return EWOULDBLOCK if they would block need to block (e.g. if the output buffer is full and you're calling send/write too often).

This forum thread has a few good points when working with non-blocking calls.