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++?



Am Montag, 16. Februar 2004 22:29 schrieb Sascha Volkenandt:
> 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).

Unfortunately that does not work for writing or maybe i did try the wrong 
things...

-checked return-value and errno after write
-select for read after write and checked errno here
-select before write and a read (i can only read 0 bytes, as i don't expect 
any byte actually there)
-write(fd,temp,0) just before the real write - still no error

The behaviour is, that only the second write that fails is actually producing
the error at the socket, write() returns an error and errno is set...

Any other thing to try?

Guido



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



Home | Main Index | Thread Index