6713809: FTP fails from multi-homed system
Summary: Binds the data socket to the same address as the control socket
Reviewed-by: michaelm
--- a/jdk/src/share/classes/sun/net/ftp/FtpClient.java Sun Jun 29 00:25:59 2008 -0700
+++ b/jdk/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())