In article <40d186ac$0$8992$(E-Mail Removed) t>
bonny_dot_gijzen_at_q-lite_dot_net (Bonny Gijzen) writes:
>Ah ok I think now I understand it:
>
>Select() indicates the socket is readable, which could mean that
>either:
>
>a) there is some data to be read
>or
>b) the socket connection has been closed (which recv() will indicate
>with resulting 0)
>
>Am I correct?
>If above is true, then my code is OK. I was just curious.
Yes, you're right on the money. If you want to continue processing
even if no data is available, you must set your socket non-blocking.
Then, if no data is ready, recv() will return -1 and errno will be
set to EAGAIN. You'll have to test for this and treat it differently
from other conditions which really _are_ errors.
Even under Windows recv() works the same way. Except, of course,
their NIH complex requires you to do a GetLastError() and check
the result for WSAEWOULDBLOCK instead of looking at errno.
--
/~\
(E-Mail Removed)lid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!