Re: Socket returns EOF prematurely

From: perry (perry_at_cplusplus.org)
Date: 06/16/04


Date: Wed, 16 Jun 2004 08:23:29 -0400

yes, i have seen this type of thing before. the problem is not with
linux, it has to do with a more efficient socket implementation on linux.

i strongly suspect your EOF is as a result of your connection is being
made too fast and either the client or the server is either not ready or
has given up.

to resolve this problem i had to implement a more intelligent connection
scheme where i would try 3 times, pausing 250 ms before each attempt...

it always seemed to get it either on the 1st or 2nd attempt, i never had
any problems after that.

i'll try to dig up the code and post it for you later

- perry

Nathan Davis wrote:
> Hi,
>
> I am having problems reading data from a socket. The problem only
> occurs while trying to read from one particular server, and does not
> occur on Windows (as far as I know, this may occur only on Linux).
>
> The server is free.teranews.com, and I am trying to connect to the NNTP
> port (119). To make things even more bizar, I only have trouble when I
> try to issue the LIST command. After issuing the command, Java will not
> return any more data, and will behave as if EOF was reached on the socket.
>
> The server *is* returning data. On windows (reading with Java), the
> data is returned, but there are a bunch of NULs in the output. I have
> not been able to find any strange characters returned by the server
> using a logging tcp proxy called ProxyView, however, so that might be a
> bug in the Windows version, or possibly a bug on the part of the test
> program I wrote.
>
> At any rate, the server interoperates as expected with every news reader
> I've tried, including Netscape and KNode, so I am a bit perplexed why
> Java on Linux is have trouble reading from the socket. Reproduction
> should be easy: just open a socket to free.teranews.net on port 119,
> write "list", and read all data until EOF. You should get a list of
> newsgroups if it work, or, if it doesn't, you'll get the Welcome message
> and then EOF.
>
> Has anyone seen this behaviour before. Any workarounds? I've tried
> this with both JDK1.4 and JDK1.5 (beta), and neither work. If you do
> get it to work, would you please post the details of your setup --
> version of Linux, JDK, etc.?
>
> Thanks,
>
> --Nathan Davis
>



Relevant Pages

  • CF GPRS-MODEM card on Intel HCCCBCTA1/Cotulla Platform,problem with serial port
    ... Linux version 2.4.19-rmk7-pxa2; ... CPU: XScale-PXA250 revision 1 ... Initializing RT netlink socket ... Keyboard reset failed, no ACK ...
    (Linux-Kernel)
  • Re: Where do I start?
    ... > I am a newcomer to Linux development, ... > the database or server scripts into the served html pages. ... Well how would you do these tasks on Windows??? ... & 2) Just like on windows, use socket calls. ...
    (comp.os.linux.development.apps)
  • Anyone know why the linux select() function is broken?
    ... 1, I sent a packet to a LAN server A, select works ... Anyone know why the linux selectfunction is broken? ... The problem I have isolated is that if a udp socket is openned, ... If there is a receiver however, ...
    (comp.os.linux.development.apps)
  • Re: epoll and timeouts
    ... descriptors to internal socket structures is probably best. ... I don't think I understand why the map is better. ... reason to not use all of the features epoll provides. ... of particular concern with Linux, ...
    (comp.unix.programmer)
  • Inconsistency in TCP sockets behavior between Windows and Linux
    ... There is an inconsistency in TCP sockets behavior between Windows and Linux, ... There are client and server applications. ... Server creates a listening socket and waits for incoming TCP connection. ...
    (microsoft.public.win32.programmer.networks)