1833858 Members
3005 Online
110063 Solutions
New Discussion

Re: Socket select call ?

 
SOLVED
Go to solution
sstan
Frequent Advisor

Socket select call ?

Dear gurus,

our application vendor encountered some abnormal behaviour in their application developed on HP-UX 11i platform. They would like to know the following:

In what condition, a socket select call on read is completed but zero bytes being returned when application tried to read the socket with readsize of 1.

regards,
3 REPLIES 3
shiwudao
Occasional Advisor

Re: Socket select call ?

when the remote close the socket, the select call is completed and zero will be read.
rick jones
Honored Contributor
Solution

Re: Socket select call ?

For a socket associated with a TCP connection a read return of zero indicates (as it does on virtually _all_ platforms) that the remote TCP has sent us a FINished segment meaning that we can expect to receive no more data from the remote.

What the local application should do with that knowledge will "depend." Depending on the application semantics, it could mean that the remote application is also no longer expecting to receive data from us.

It could also mean that the remote process died for some reason. When the process died, and all its file descriptors were close()'d that would have triggered the FIN to be sent.

For a socket associated with a UDP endpoint a zero byte return from read() et al means simply that someone sent use a zero-length UDP datagram.

For a socket associated with other protocols, it will depend on the protocol.

A read return of zero meaning remote close for TCP is a pretty fundamental thing. I would have expected an application vendor to be aware of that. If they were not, I would be somewhat concerned about their ability to write a "proper" sockets-using application.

there is no rest for the wicked yet the virtuous have no pillows
sstan
Frequent Advisor

Re: Socket select call ?

thanku all