Search code examples
c++ciononblocking

How to get IO errors in `O_NONBLOCK`ed code?


Once I have enabled O_NONBLOCK, and then call a non-blocking function, and after it returns some I/O error happens, how may I get to know that something bad has happened, and how to handle it?


Solution

  • You get the errors when they are ready for you to see them and you are ready to receive them.

    sooner or later you end up calling read() or close() or whatever and that will give you the error.