Re: Question on select() and sockets
- From: K-mart Cashier <cdalten@xxxxxxxxx>
- Date: Fri, 6 Jun 2008 18:31:34 -0700 (PDT)
On Jun 6, 2:07 pm, Alex Fraser <m...@xxxxxxxxxxx> wrote:
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/b589bcb9068...
Alex
Perhaps I'm not thinking this through, but how
"This all sounds fine. But you must set the pipes non-blocking else
you
can still end up blocking, even if you only call read() or write()
after
select() says the descriptor is, respectively, readable or writeable:
Is this possible?
Chad
.
- Follow-Ups:
- Re: Question on select() and sockets
- From: David Schwartz
- Re: Question on select() and sockets
- From: William Ahern
- Re: Question on select() and sockets
- From: Barry Margolin
- Re: Question on select() and sockets
- References:
- Question on select() and sockets
- From: K-mart Cashier
- Re: Question on select() and sockets
- From: Alex Fraser
- Question on select() and sockets
- Prev by Date: Re: how to fork/exec and not wait for child
- Next by Date: Re: how to fork/exec and not wait for child
- Previous by thread: Re: Question on select() and sockets
- Next by thread: Re: Question on select() and sockets
- Index(es):
Relevant Pages
|
Loading