From: Nigel Wade on
On Tue, 09 Feb 2010 20:51:26 -0800, horos wrote:

> All,
>
> I've been trying to get a passive ftp server working, but unfortunately,
> there seems to be a VERY low level bug in the Socket command that makes
> the passive connection.
>
> The symptoms: I get a port to connect to, and then try that port using:
>
> Socket sckt = new Socket(host, port);
>
> The socket sends off a SYN_SENT but hangs in waiting for response.

The most likely reason is that something is dropping that SYN packet, or
the response. If the SYN was received by a listening server it would
respond with a SYN/ACK. If there is nothing listening then the host
responds with an RST. The only scenario that I can think of where a SYN
is sent but no SYN/ACK or RST is returned is if the server socket is
setup to queue connections (it's quite a while since I did any work at
this level so my memory is very hazy on the actual specifics). If the
server is already serving a connection new connection attempts are
queued, up to some set limit, until they are either accepted or time out.

You should look at the network traffic on the client and server to see
what packets are really being sent and received. Also check the server to
see what connections it already has established and whether it queues
requests. I would suspect a mis-configured (or misunderstood) firewall
somewhere in the route.

>
> Now I don't know for sure, but I STRONGLY suspect that it is a java bug.
> Why? The Socket connection worked before (ie: this is old production
> code). Regular ftp worked. Net::FTP, the perl implementation of ftp
> works.

Java is not responsible for the SYN-SYN/ACK-ACK three-way handshake. Java
works at the process layer (layers 5, 6 & 7 of the OSI 7-layer model).
This handshake takes place at the transport layer (level 4 in OSI). Java
relies on the OS via system calls to handle the lower layers. I see no
way that a bug in Java could cause symptoms you describe.

>
> So it looks like there is a strong likelihood there is a bug in socket
> itself. I'd love to hear from sun on this one, I can both demo the code
> that isn't working, and hopefully file a bug report.. I''m on jdk6.12,
> but am upgrading to jdk6.18.
>

I disagree. I don't see how this is due to a bug in Java.

--
Nigel Wade
From: Christian on
Am 10.02.2010 05:51, schrieb horos:
> All,
>
> I've been trying to get a passive ftp server working, but
> unfortunately, there seems to be a VERY low level bug in the Socket
> command that makes the passive connection.
>
> The symptoms: I get a port to connect to, and then try that port
> using:
>
> Socket sckt = new Socket(host, port);
>
> The socket sends off a SYN_SENT but hangs in waiting for response.

sort of there is a low level bug...
the constructor you are using should not be used as you can't specify a
timeout with it.
it might be better to use the empty constructor and then provide address
with connect() and a timeout...

I have often had problems with sockets blocking forever under certain
cicumstances.. (like very unusal kind of connection breaks ...like
outside IP of NAT changes while connection is running or other sort of
breakdowns, primarily problems of TCP itself as it can't detect broken
line without traffic so mainly programming/protocol errors).

Best solution for me was to use NIO but ymmv.

Christian