Problem with ReadAndX

Derrell Lipman derrell.lipman at
Wed Jan 21 14:15:59 GMT 2009

On Wed, Jan 21, 2009 at 7:11 AM, MaheNabble <shmahendran at> wrote:

> The problem that I have is, when I try to read a file (which is of 4 bytes,
> just a txt file), the client sends READ_ANDX command about 40 times and
> after a long time (about 45 seconds), it opens the file. After some
> investigation, I noticed that there is a request (packet no 370) in which
> it
> expects only 4 bytes of data from the offset 0x0000, there the ReadAndX
> ends.

This appears to be an application issue, not a protocol issue. I don't see
any problem in the packet capture. You open the text file, request to read
up to 256 bytes, get back a response that contains 4 bytes (since that's all
there is in the file), read again from offset 4 and get a response that says
there's no more data (0 bytes returned), and you should be done. Your next
operation on that file id is to request up to  512 bytes from offset 0. You
again get the available 4 bytes, request 508 now, and get back 0 since
you've reached end of file. Your application repeats this process a few
times with 512 byte requests then ups it to a 960 byte request, etc.
Whatever is going on here is not protocol related, but rather is related to
the application issuing the ReadAndX requests.

I am not sure why there are so many request for just to read 4 bytes of
> data. Why is it not succeeded in the first ReadAndX itself? Why is it
> expecting 256 bytes of data (in the packet 121) instead of 4 bytes?

How is it supposed to know how big the file is without asking? It's
requesting *UP TO* 256 bytes and is given back the 4 bytes that are in the
file. Why it doesn't stop reading when it gets back 0 bytes from the next
read, I have no way of knowing.


More information about the samba-technical mailing list