sim: use gnulib to set nonblocking mode

Replace various custom ad-hoc fcntl/O_NONBLOCK implementations with
the gnulib nonblocking module.  This makes our code much tidier and
portable to other systems (e.g. Windows).
4 files changed