changeset 445:571a6e4bbb91

6713809: FTP fails from multi-homed system Summary: Binds the data socket to the same address as the control socket Reviewed-by: michaelm
author jccollet
date Tue, 01 Jul 2008 13:29:36 +0200
parents 47c4a285e238
children b6a29195bc04
files src/share/classes/sun/net/ftp/FtpClient.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/ftp/FtpClient.java	Sun Jun 29 00:25:59 2008 -0700
+++ b/src/share/classes/sun/net/ftp/FtpClient.java	Tue Jul 01 13:29:36 2008 +0200
@@ -352,6 +352,9 @@
                 s = new Socket(Proxy.NO_PROXY);
         } else
             s = new Socket();
+        // Bind the socket to the same address as the control channel. This
+        // is needed in case of multi-homed systems.
+        s.bind(new InetSocketAddress(serverSocket.getLocalAddress(),0));
         if (connectTimeout >= 0) {
             s.connect(dest, connectTimeout);
         } else {
@@ -417,8 +420,10 @@
             // since we can't accept a connection through SOCKS (yet)
             // throw an exception
             throw new FtpProtocolException("Passive mode failed");
-        } else
-            portSocket = new ServerSocket(0, 1);
+        }
+        // Bind the ServerSocket to the same address as the control channel
+        // This is needed for multi-homed systems
+        portSocket = new ServerSocket(0, 1, serverSocket.getLocalAddress());
         try {
             myAddress = portSocket.getInetAddress();
             if (myAddress.isAnyLocalAddress())