Re: Question on select() and sockets



K-mart Cashier wrote:
Why do sockets have to be 'non-blocking' when using select() to set
the timeout? Ie, why can't they be blocked?

You can use blocking calls to send()/recv()/read()/write() if you don't care if you block in them - but I don't think that should ever be the case if you are using select().

Making the sockets non-blocking guarantees control over when you block (ie, in select()). Although I was writing about pipes in my recent reply to Edd, the same applies to sockets (first block of my reply):

http://groups.google.co.uk/group/comp.unix.programmer/msg/b589bcb9068e0420

Alex
.


Loading