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 Dienstag, 17. Februar 2004 20:28 schrieb Guido Fiala:
> Unfortunately that does not work for writing or maybe i did try the wrong
> things...
No, you would have to check for reading before writing, actually, if you want
to be sure the socket is open.
> -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
EOF isn't an error. It just means that the kernel signals "reading now
possible", but actually returns 0 byte on reading. If the socket is open, but
there is nothing available, select/poll don't signal the socket as
readable...
So:
- select() on the socket for reading, timeout 0 (return immediately)
- select returns "nothing readable" -> socket open, go on with writing
- select returns "something readable" and a subsequent read returns something
-> go on with interpreting the data :)
- select returns "something readable" but a subsequent read returns 0 ->
socket is closed
So, you see, there's no error involved here (since all commands return ok),
because EOF is not an error condition, but just EOF :-))
Greetings,
Sascha
--
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.
Home |
Main Index |
Thread Index