diff options
author | Brian P. Hinz <bphinz@users.sf.net> | 2019-11-06 19:24:16 -0500 |
---|---|---|
committer | Brian P. Hinz <bphinz@users.sf.net> | 2019-11-06 19:26:53 -0500 |
commit | 9de48d47ac6ca5974d5b7f2488cb68767371214c (patch) | |
tree | 452cd48559c1a56d39d23b7b46fdec89073ae9f8 /java | |
parent | 512d940e7e0392993446822b7d67adb9aaf374ca (diff) | |
download | tigervnc-9de48d47ac6ca5974d5b7f2488cb68767371214c.tar.gz tigervnc-9de48d47ac6ca5974d5b7f2488cb68767371214c.zip |
Set explicit connect timeout on socket and use timer instead of counting iterations
Diffstat (limited to 'java')
-rw-r--r-- | java/com/tigervnc/vncviewer/Tunnel.java | 5 |
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) { |