What is socket select?
The select function is used to determine the status of one or more sockets. For each socket, the caller can request information on read, write, or error status. The set of sockets for which a given status is requested is indicated by an fd_set structure.
What is socket blocking mode?
A socket is in blocking mode when an I/O call waits for an event to complete. Some APIs, in addition to nonblocking calls, support asynchronous socket calls. Blocking. The default mode of socket calls is blocking. A blocking call does not return to your program until the event you requested has been completed.
How do you make a socket Nonblock?
Change a socket to nonblocking mode using the ioctl() call that specifies command FIONBIO and a fullword (four byte) argument with a nonzero binary value. Any succeeding socket calls against the involved socket descriptor are nonblocking calls.
What is the difference between blocking and non-blocking sockets?
In blocking mode, the recv, send, connect (TCP only) and accept (TCP only) socket API calls will block indefinitely until the requested action has been performed. In non-blocking mode, these functions return immediately. select will block until the socket is ready.
How does select () work?
select() works by blocking until something happens on a file descriptor (aka a socket). Data coming in or being able to write to a file descriptor — you tell select() what you want to be woken up by.
Is select () blocking?
When you return to select() it blocks, waiting for more data. However your peer on the other side of the connection is waiting for a response to the data already sent. Your program ends up blocking forever. You could work around it with timeouts and such, but the whole point is to make non-blocking I/O efficient.
Is select non-blocking?
select() has a timeout. You can use a timeout of 0 seconds to poll the requested socket(s) and exit immediately without blocking. He can call select() in a loop, requesting both TCP and UDP sockets at the same time.