Comments
www.faqs.org/faqs/unix-faq/socket
Posted by crouse
www.hiraeth.com/alan/tutorials/courses/tcpip.html - 13k -
Posted by waqasahmad
* int status = select(nfds, &readfds, &writefds, &exceptfds, &timeout);
- status: # of ready objects, -1 if error
- nfds: 1 + largest file descriptor to check
- readfds: list of descriptors to check if read-ready
- writefds: list of descriptors to check if write-ready
- exceptfds: list of descriptors to check if an exception is registered
- timeout: time after which select returns, even if nothing ready - can be 0 or ¥
(point timeout parameter to NULL for ¥)
* Recall select uses a structure, struct fd_set
- it is just a bit-vector
- if bit i is set in [readfds, writefds, exceptfds], select will check if file descriptor (i.e. socket) i is ready for [reading, writing, exception]
* Before calling select:
- FD_ZERO(&fdvar): clears the structure
- FD_SET(i, &fdvar): to check file desc. i
* After calling select:
- int FD_ISSET(i, &fdvar): boolean returns TRUE iff i is “ready”
Posted by peter186