Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: how detect vdr has closed socket in c++?



On Mon, 16 Feb 2004, Sascha Volkenandt wrote:

> Am Montag, 16. Februar 2004 20:46 schrieb Guido Fiala:
> > As to allow to set a small SVDRP-timeout without kvdr loosing a command -
> > how to detect if vdr has closed the socket?
> >
> > I tried to check errno after calling write(), but this helps just after the
> > second write()-operation on the socket and then it's too late.
> > Some other way i missed?
>
> Well, not sure if this is the cleanest way, but I usually try if a socket is
> signalled for reading (means poll for read returns true on this socket), and
> if a subsequent read returns 0, that signals eof, meaning the socket is
> closed (at least for reading, but this usually is enough).

Well, the way you usually do that is, you make a select call before a read
or write operation, if select says reading is allowed a read receives an
eof then the connection is closed by the foreign host. See select(2) for
more help.

Patrick


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index