[sane-devel] Network connected scanner, i/o error if scanner is idle for longer then 40sec

Paul Newall p.newalls at ntlworld.com
Tue Dec 30 17:26:42 UTC 2014


On 30/12/14 10:18, Louis Lagendijk wrote:
> On Tue, 2014-12-30 at 10:09 +0000, Paul Newall wrote:
>> I have been digging down into the code, and adding extra debug output.
>> In my network read function kodakaio_net_read it seems that poll(...) is
>> indicating that there is data to read, but sanei_ tcp_read(..) then
>> returns zero bytes.
>> If there was no data I'd expect poll to timeout, and if there was some
>> data, sanei_ tcp_read should return it?
>> But this is the only network read code I have ever written in c so I am
>> not too confident it is correct.
>>
>> Paul
> A read returning 0 bytes when the fd is ready indicates that the other
> side closed the TCP-connection. you probably need to send some form of
> keep-alive or close/ the connection when you don't need it and re-open
> the connection later.
> Louis
>
>
Thank you Louis, that was very helpful.
It seems that the scanner initiates keep-alive exchanges every 3 seconds 
for around 27 seconds, then it closes the connection.

I had assumed the normal thing would be to open the connection in 
sane_open, and close it in sane_close,
but perhaps it's better to open the connection in sane_start, and close 
it in sane_cancel.

Or I could leave things more or less as they  are, but detect the loss 
of connection and reopen it if required.

Paul





More information about the sane-devel mailing list