C/C++ – non blocking file descriptor

by

If you got an input file descriptor by using open() (<unistd.h>) or other function that creates a file descriptor and you want to set the descriptor to be non blocking on read, you can do:

fcntl(file_desc, F_SETFL, O_NONBLOCK); // <fcntl.h>

Advertisements

One Response to “C/C++ – non blocking file descriptor”

  1. bengaltiger Says:

    Fantastic tip! Your source is great.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: