Bug with FIONREAD for TCP?

From: Richard Gooch (rgooch@ras.ucalgary.ca)
Date: Mon Apr 10 2000 - 01:15:20 EST


  Hi, all. For at least a month or two I've noticed that FIONREAD
yields 1 byte on a freshly closed TCP connection, rather than 0.

The server creates a socket, binds to a port and listens and accepts
the first connection. It does a select(2) on the FD, and upon an input
event, calls ioctl(2) with FIONREAD. This yields 1 byte readable. Any
attempt to read that byte fails, as it's not really there.

The client connects, waits a second, then calls close(2). It doesn't
matter if the client writes some data (which the server reads), the
server still gets 1 byte readable when the connection closes. This
really doesn't seem right, since there is no data to read. Besides,
how else is the server to know that the "input" event is in fact a
closure (I can't use poll(2))?

2.3.99-pre4-2 still has this problem.

                                Regards,

                                        Richard....
Permanent: rgooch@atnf.csiro.au
Current: rgooch@ras.ucalgary.ca

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:13 EST