Hi,

On Fri, Oct 15, 2004 at 04:03:04PM +0200, Johannes Berg wrote:
> somehow saned/the sanei network layer seem to get buffering wrong.

I'm afraid that that's intentional. But that's only a guess.

> For example, I send the following:
> 
> SANE_NET_INIT
> SANE_NET_GET_DEVICES
> SANE_NET_EXIT
> 
> If I don't wait for the result from SANE_NET_GET_DEVICES before sending
> the control code for SANE_NET_EXIT, then the SANE_NET_EXIT code is
> discarded.

I think you must really read the result of any RPC before sending the
next one.

> I would assume that somewhere there's a buffering problem and the old
> buffer is simply dropped when the direction is changed or something.

That's done in sanei_w_set_direction().
Set SANE_DEBUG_SANEI_WIRE=255 and you'll even get a warning :-)

> The following works:
> (echo  -n -e \\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00 ;
> sleep .1 ; echo -n -e \\00\\00\\x00\\x01 ; sleep 1 ;
> echo -en \\x00\\x00\\x00\\x0A ) | nc localhost 6566 -q 1 | hd
> 
> while this doesn't:
> (echo  -n -e \\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00 ;
> sleep .1 ; echo -n -e \\00\\00\\x00\\x01\\x00\\x00\\x00\\x0A
> )| nc localhost 6566 -q 1 | hd
> 
> I think this is extremely counter-intuitive. TCP never guarantees
> message boundaries, so one wouldn't think that data is explicitly read
> by the application but then discarded.
 
I guess you are right but I don't really know how to fix that with the
current code. One option would be to set the wire to error state (and
exit?) when data is discarded.

Bye,
  Henning

Reply via email to