Sign in to follow this  
faculaganymede

Clarification on usage of select() in C/C++ App

Recommended Posts

Hi all, I found two documents that explains the usage of select(): 1. doc 1: "The select function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O." 2. doc 2: "The select() function supports regular files, terminal and pseudo-terminal devices, STREAMS-based files, FIFOs and pipes. The behaviour of select() on file descriptors that refer to other types of file is unspecified." I am confused, is select() supposed to be used for sockets only, or used for all I/O devices?? If used for all I/O devices, where/how does one specify the device of interest. Thanks.

Share this post


Link to post
Share on other sites
Like all unix I/O a socket is indistinguishable from a file. So, anything that has a file descriptor (sockets included ) can be used with select().

Edit: that is for unix only.

On windows select is a call to the wsock library, and can only be used on sockets.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this