提交 573d9e8b 编写于 作者: J jccollet

6713809: FTP fails from multi-homed system

Summary: Binds the data socket to the same address as the control socket
Reviewed-by: michaelm
上级 efe3441c
......@@ -352,6 +352,9 @@ public class FtpClient extends TransferProtocolClient {
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 @@ public class FtpClient extends TransferProtocolClient {
// 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())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册