[ECOS] network problems

Jonathan Larmour jifl@eCosCentric.com
Fri Apr 11 22:29:00 GMT 2003


Andrew Lunn wrote:
>>My problem is, I use select to wait for multiple inputs including the socket.
>>Normally I recognize the a connection was closed by peer if read() returns 0 
>>or I get an error while write().
>>But sometimes I have the case, the I stop reading and writing to the socket
>>for some reasons. So I just don't set the corresponding bit in the fdset.
>>but in such state I can't recognize if the connection is closed.
> 
> 
> Try setting the bit in exceptfds. I think select will then report when
> the socket is closed.

I'd be interested to know for other reasons if this is true! AFAIK 
exceptfds is only used for OOB data.

BTW, did you really mean ferror() rather than 
getsockopt(...,SO_ERROR,...)? Although in either case I'm not entirely 
sure they'd ever get set unless some operation is done on the socket 
first. Looking at the freebsd stack source, it looks like the getsockopt 
should probably work, but I also don't know if that's BSD-specific behaviour.

Jifl
-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list