I'm doing some socket programming using the POSIX interface. I'm trying to use the select() function to monitor when a nonblocking socket is ready to be read/write.
When using the select() function, I give it a set of read and write file descriptors. Specifically, I have a single socket fd that I want to check if it is both readable and writable.
The POSIX documentation states that the return value is a sum of all file descriptors featured in all the fd sets.
My early testing shows that I get a '2' back which is good (that means my socket is both readable and writable). However, what happens if the file descriptor doesn't simultaenous become both readable/writable? Say it becomes readable a microsecond before it becomes writable? What happens? Does it just return a 1?