Mercurial > hg > Members > nobuyasu > tightVNCClient
changeset 48:67655ba93e92
reconnection at connecton faild
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 11 Jul 2011 14:39:24 +0900 |
parents | 9f6b211d0d1e |
children | a9e0284cc29c |
files | src/myVncClient/MyVncClient.java src/myVncClient/echoClient.java |
diffstat | 2 files changed, 20 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/myVncClient/MyVncClient.java Sat Jul 09 14:39:53 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Mon Jul 11 14:39:24 2011 +0900 @@ -120,7 +120,8 @@ System.out.println("Socket error"); // parent no find Random rnd = new Random(); - int ran = rnd.nextInt(500) + 500; + long ran = rnd.nextInt(5000) + 5000; + System.out.println(ran); while (true) { try { @@ -128,12 +129,12 @@ } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); - - echo = new echoClient(); - echo.openport(); - echo.losthost(); } + echo = new echoClient(); + echo.openport(); + echo.losthost(); } + // System.exit(0); } catch (Exception e) { System.out.println(e); @@ -693,11 +694,11 @@ * port = readIntParameter("PORT", 5550); */ if (value == null) { - String pHost; - if (mainArgs.length > 0) pHost = mainArgs[0]; - else pHost = "cls080.ie.u-ryukyu.ac.jp"; if (clientSocket == null) { + String pHost; + if (mainArgs.length > 0) pHost = mainArgs[0]; + else pHost = "cls080.ie.u-ryukyu.ac.jp"; echo = new echoClient(pHost); echo.openport();
--- a/src/myVncClient/echoClient.java Sat Jul 09 14:39:53 2011 +0900 +++ b/src/myVncClient/echoClient.java Mon Jul 11 14:39:24 2011 +0900 @@ -2,6 +2,7 @@ import java.io.*; import java.net.*; +import java.util.Random; public class echoClient { public static Revalue value = new Revalue(); @@ -15,6 +16,8 @@ Socket clientSocket = null; ServerSocket echoServer = null; public static String name; + + // WaitReplyに自分自身を渡している public echoClient() { @@ -29,7 +32,10 @@ // Revalue hostn(String args){ void openport() { // ソケットや入出力用のストリームの宣言 - + /* + Random rnd = new Random(); + long ran = rnd.nextInt(1000) + 1000; +*/ // ポート9999番に接続 try { if (name != null) { @@ -42,6 +48,7 @@ } catch (UnknownHostException e) { System.err.println("Don't know about host: localhost"); } catch (IOException e) { + System.out.println("接続に失敗しました"); System.err .println("Couldn't get I/O for the connection to: localhost"); } @@ -139,7 +146,7 @@ * if ((value.treenum = is.readLine()) != null) { * System.out.println("treenum: " + value.treenum); } */ - //Thread.sleep(1000); + Thread.sleep(1000); MyVncClient.main(value); // 開いたソケットなどをクローズ @@ -152,11 +159,11 @@ } catch (IOException e) { System.err.println("IOException: " + e); } - /*catch (InterruptedException e) { + catch (InterruptedException e) { // TODO Auto-generated catch block in order to thread sleep e.printStackTrace(); } -*/ + } return value; }