A file descriptor is put into “nonblocking mode” by adding O_NONBLOCK to the set of fcntl flags on the file descriptor:

/* set O_NONBLOCK on fd */
int flags = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, flags | O_NONBLOCK);

On blocking syscall (read, write), it returns -1 and errno is set to EWOULDBLOCK

It will then need a loop to check if the fd has data ready. So we need a IO Multiplexer to make it performant.