[luau] the evil # 1460

Jimen Ching jching at flex.com
Fri Apr 26 01:50:35 PDT 2002


On Thu, 25 Apr 2002, Charles Lockhart wrote:
>                bytes_recvd = read(sockfd, &data[bytes_total], CLK_BUF_SIZE);
                                                                ^^^^^^^^^^^
Should that be (CLK_BUF_SIZE - bytes_total)?  Otherwise, you might
actually read more than CLK_BUF_SIZE.  Also, how did you determine
data_len?  And is sockfd using TCP, UDP, or RAW sockets?

>                if(bytes_recvd < 0)

If bytes_recvd is zero, it means the socket closed.  This code does not
handle that case.  I assume the read() system call is a blocking read?

>out.write() from the client ends up being seen as two seperate  reads on the
>server, the first always being 1460 bytes, the second being the remainder,
>and I get a bunch of 0's pushed into the data as well (gee, would you
>believe 1460 of them?), and then the data begins where it left off,
>essentially cutting off the last 1460 bytes of my data.

I'm kind of confused about this description.  How many bytes were written?
If there was two reads of 1460, then there must have been 2920 bytes read.
If the first read got valid data, and the second read got all zeros, how
do you know the 'data begins where it left off'?

As for the difference between Windows and Linux behavior.  If this is
ethernet, which I believe it is, then both systems will have sent the data
in fragments that are at most 1460 bytes.  The reason why you read
everything from Linux, and Windows has to read multiple times is because
Windows is slow.  In the case of Linux, the second fragment must have been
received and _processed_ by the time the read system call was handled.
But Windows was slow, so the second fragment only arrived after the read
call was handled.

I do not know java, so I can not rule out a problem on the client side.
Does the out.write routine behave the same as the write() system call?

--jc
--
Jimen Ching (WH6BRR)      jching at flex.com     wh6brr at uhm.ampr.org





More information about the LUAU mailing list