If I make a TCP socket descriptor non blocking using fcntl(sockfd, F_SETFL, O_NONBLOCK);, does that make all the subsequent socket API's like read()/listen()/accept()/ etc.. also non blocking?
If I make a TCP socket descriptor non blocking using fcntl(sockfd, F_SETFL, O_NONBLOCK);, does that make all the subsequent socket API's like read()/listen()/accept()/ etc.. also non blocking?
There's an official answer in a man page, specifically socket(7):
It is possible to do nonblocking I/O on sockets by setting the O_NONBLOCK flag on a socket file descriptor using fcntl(2). Then all operations that would block will (usually) return with EAGAIN (operation should be retried later); connect(2) will return EINPROGRESS error. The user can then wait for various events via poll(2) or select(2).
So yes, setting O_NONBLOCK will cause blocking operations to return EAGAIN/EINPROGRESS instead of blocking.