diff src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java @ 43:6687aa9dd55e

add flag for screen change in ReciverTask.java.
author one
date Tue, 06 Nov 2012 15:36:46 +0900
parents fe38611c4b2b
children d4663dfd91ae
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java	Thu Oct 25 19:38:20 2012 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java	Tue Nov 06 15:36:46 2012 +0900
@@ -24,11 +24,10 @@
 		this.echoPort = echoPort;
 		this.name = name;
 	}
-	
 
 	public void openport() {
 		try {
-			//if(echoSocket==null)
+			// if(echoSocket==null)
 			echoSocket = new Socket(name, echoPort);
 			echoSocket.setReuseAddress(true);
 			os = new DataOutputStream(echoSocket.getOutputStream());
@@ -66,7 +65,7 @@
 			} catch (IOException e) {
 				System.err.println("IOException: " + e);
 			}
-			waitReply = new WaitReply(treeNum,this);
+			waitReply = new WaitReply(treeNum, this);
 			waitReply.start();
 		}
 		return this;
@@ -169,12 +168,15 @@
 	}
 
 	void reConnectionMain(Socket echoSocket) {
-		try {
-			client.close();
-			client.setSocket(createSocketForClient(echoSocket));
-			client.run();
-		} catch (IOException e) {
-			e.printStackTrace();
+		while (true) {
+			try {
+				client.close();
+				client.setSocket(createSocketForClient(echoSocket));
+				client.run();
+				break;
+			} catch (IOException e) {
+				continue;
+			}
 		}
 	}
 
@@ -211,7 +213,7 @@
 			System.err.println("IOException: " + e);
 		}
 	}
-	
+
 	public void getParentName() {
 		if (clientSocket == null) {
 			// echo = new EchoClient(pHost, this);
@@ -231,12 +233,12 @@
 				soc.getInputStream()));
 		String tempParentAddress = is.readLine();
 		parentNum = is.readLine();
-		if("reconnection".equals(tempParentAddress)) {
+		if ("reconnection".equals(tempParentAddress)) {
 			System.out.println("-----------------into function \n" + parentNum);
-			return new Socket(parentAddress,Integer.parseInt(parentNum));
-		} 
+			return new Socket(parentAddress, Integer.parseInt(parentNum));
+		}
 		treeNum = is.readLine();
 		leaderFlag = is.readLine();
-		return new Socket(tempParentAddress,5999);
+		return new Socket(tempParentAddress, 5999);
 	}
 }
\ No newline at end of file