提交 afc64a83 authored 作者: Thomas Mueller's avatar Thomas Mueller

Problems when using a VPN that does not allow connections from within the same computer.

上级 3c5a9b62
...@@ -729,12 +729,27 @@ public class Build extends BuildBase { ...@@ -729,12 +729,27 @@ public class Build extends BuildBase {
}; };
thread.start(); thread.start();
Thread.sleep(1000); Thread.sleep(1000);
Socket socket = new Socket(); final Socket socket = new Socket();
socket.setSoTimeout(2000); socket.setSoTimeout(2000);
InetSocketAddress socketAddress = new InetSocketAddress(address, port); final InetSocketAddress socketAddress = new InetSocketAddress(address, port);
System.out.println("client:" + socketAddress); System.out.println("client:" + socketAddress);
try { try {
socket.connect(socketAddress, 2000); Thread t = new Thread() {
public void run() {
try {
socket.connect(socketAddress, 2000);
} catch (IOException e) {
e.printStackTrace();
}
}
};
t.start();
t.join(5000);
if (!socket.isConnected()) {
final InetSocketAddress localhostAddress = new InetSocketAddress("localhost", port);
System.out.println("not connected, trying localhost:" + socketAddress);
socket.connect(localhostAddress, 2000);
}
Thread.sleep(200); Thread.sleep(200);
System.out.println("client:" + socket.toString()); System.out.println("client:" + socket.toString());
socket.getOutputStream().write(123); socket.getOutputStream().write(123);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论