Mercurial > hg > Applications > TightVNC_orginal
changeset 44:d4663dfd91ae
add reconnection process when the connection fails.
author | one |
---|---|
date | Sun, 18 Nov 2012 18:47:14 +0900 |
parents | 6687aa9dd55e |
children | 20326a4b9d88 |
files | src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java |
diffstat | 3 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Nov 06 15:36:46 2012 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Sun Nov 18 18:47:14 2012 +0900 @@ -129,7 +129,7 @@ echo.notfoundParent(); } if(echo.lostHost()) break; - counter++; + counter++; } } else if (isRunning) { logger.severe("Close proxy: ");
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java Tue Nov 06 15:36:46 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java Sun Nov 18 18:47:14 2012 +0900 @@ -175,6 +175,7 @@ client.run(); break; } catch (IOException e) { + System.out.println("EchoClient L178"); continue; } } @@ -231,11 +232,23 @@ public Socket createSocketForClient(Socket soc) throws IOException { BufferedReader is = new BufferedReader(new InputStreamReader( soc.getInputStream())); + int count=0; String tempParentAddress = is.readLine(); parentNum = is.readLine(); if ("reconnection".equals(tempParentAddress)) { System.out.println("-----------------into function \n" + parentNum); - return new Socket(parentAddress, Integer.parseInt(parentNum)); + while(true) + try{ + return new Socket(parentAddress, Integer.parseInt(parentNum)); + } catch(IOException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + if(count++ > 5) break; + continue; + } } treeNum = is.readLine(); leaderFlag = is.readLine();
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java Tue Nov 06 15:36:46 2012 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java Sun Nov 18 18:47:14 2012 +0900 @@ -38,12 +38,14 @@ echo.client.setSocket(echo.createSocketForClient(clientSocket)); // hult(); // client.init(); + System.out.println("------before run()"); echo.client.run(); echoServer.close(); } } catch (BindException e) { break; } catch (IOException e) { + System.out.println("Error in WaitReply L47"); System.out.println(e); } }