aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2019-11-06 19:24:16 -0500
committerBrian P. Hinz <bphinz@users.sf.net>2019-11-06 19:26:10 -0500
commit5523480b0f287e7a0e78564bf2933ce96c3c0a83 (patch)
tree6ef485efce32f79dad33cbb1c0899fa2131e6b35
parent9ab28ef32da019441821ddac68cda77075a8a371 (diff)
downloadtigervnc-5523480b0f287e7a0e78564bf2933ce96c3c0a83.tar.gz
tigervnc-5523480b0f287e7a0e78564bf2933ce96c3c0a83.zip
Set explicit connect timeout on socket and use timer instead of counting iterations
-rw-r--r--java/com/tigervnc/vncviewer/Tunnel.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/java/com/tigervnc/vncviewer/Tunnel.java b/java/com/tigervnc/vncviewer/Tunnel.java
index 2d0c61f5..ef5be279 100644
--- a/java/com/tigervnc/vncviewer/Tunnel.java
+++ b/java/com/tigervnc/vncviewer/Tunnel.java
@@ -212,7 +212,8 @@ public class Tunnel {
Thread t = new Thread(new ExtProcess(cmd, vlog, true));
t.start();
// try for up to 5s
- for (int i=0;i<50;i++) {
+ long start = System.currentTimeMillis();
+ while (System.currentTimeMillis() - start < 5000) {
if (isTunnelReady(localPort))
return;
else
@@ -232,7 +233,7 @@ public class Tunnel {
java.net.Socket socket = new java.net.Socket();
boolean ready = false;
try {
- socket.connect(sockAddr);
+ socket.connect(sockAddr, 1000);
ready = socket.isConnected();
socket.close();
} catch (IOException e) {