select no setting the read flag
select no setting the read flag
- Subject: select no setting the read flag
- From: Nicolas Berloquin <email@hidden>
- Date: Wed, 26 May 2004 23:09:44 +0200
Hello !!
I'm having a very strange problem with select() in my application.
I now handle all my tcp traffic myself with a central select() call,
and recvfrom() and sendto() calls.
The problem in short:
Some incoming (fully connected) connexions remain with bytes in the
TCP receive queue (netstat), while select never sets the read flag on
them.
The general context:
- All my sockets are non-blocking, and select() is called
non-blockingly also (This may not be the best way,
but it's really the most convenient way for me).
- I have a listen socket that waits for select to set the accept bit on
its descriptor.
- Each connection that I create after the accept call has internal
flags for read and writability.
They're then added to the select loop.
- I only put connexions that have their flags to FALSE inside the
select rd/wr bitfields.
- When a descriptor is created after an accept(), I set the read and
write internal flags to TRUE,
generating a recvfrom() a little later on (but before the next select
call).
- Everytime a read bit is set by select, recvfrom is called afterwards.
- After a recvfrom(), I set the read flag back to FALSE. (and for
sendto(), I only set it to FALSE if I get EWOULDBLOCK).
- Most connexions return EAGAIN after the first call to recvfrom(),
some seem to have a little data
that arrived between the accept call and the read.
- Independently from this benign EAGAIN, some connexions remain a long
time (until my timeout
prunes them) with some data in the receive queue, and select never
setting their read bit.
I've been searching and logging and searching and I can't see where the
catch is.
I didn't find anything to correlate with this behavior, since a lot of
incoming connexions work like a charm...
Any hint would be greatly appreciated ;-)
thanks !
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.