diff src/myVncClient/WaitReply.java @ 79:c76e43a12796

modify MyVncClient
author e085711
date Wed, 31 Aug 2011 13:34:32 +0900
parents 7d25b08f5835
children 3bfe8845684c
line wrap: on
line diff
--- a/src/myVncClient/WaitReply.java	Tue Aug 30 18:33:24 2011 +0900
+++ b/src/myVncClient/WaitReply.java	Wed Aug 31 13:34:32 2011 +0900
@@ -3,63 +3,53 @@
 import java.net.*;
 import java.io.*;
 
-
 public class WaitReply extends Thread {
-//	MyVncClient client;
+	// MyVncClient client;
 	InterfaceForViewer client;
 	private String treenum;
 
+	/*
+	 * public WaitReply(String treenum,MyVncClient client) { this.client =
+	 * client; this.treenum = treenum; }
+	 */
 
-/*	
-	public WaitReply(String treenum,MyVncClient client) {
-		this.client = client;
-		this.treenum = treenum;
-	}
-*/
-
-	public WaitReply(String treenum,InterfaceForViewer client) {
+	public WaitReply(String treenum, InterfaceForViewer client) {
 		this.client = client;
 		this.treenum = treenum;
 	}
 
-	
-	public void run(){
+	public void run() {
 		Socket clientSocket = null;
-		ServerSocket echoServer=null;
-		//boolean mainFlag;
-		
-		while(true){
+		ServerSocket echoServer = null;
+		// boolean mainFlag;
+
+		while (true) {
 			try {
 				echoServer = new ServerSocket(10001 + Integer.parseInt(treenum));
-			}
-			catch (IOException e) {
+			} catch (IOException e) {
 				System.out.println(e);
 			}
 			try {
-			clientSocket = echoServer.accept();
-			if(clientSocket != null){
-				client.close();
-				
-//				client.clientSocket = clientSocket;
-				client.setClientSocket(clientSocket);
-				client.init();
-				client.start_threads();
-				client.start();
-				//MyVncClient.main(clientSocket);
-				//echo.Interruption(clientSocket);
-			}
-			
-			}catch (IOException e){
+				clientSocket = echoServer.accept();
+				if (clientSocket != null) {
+					client.close();
+					// client.clientSocket = clientSocket;
+					client.setClientSocket(clientSocket);
+					client.init();
+					client.start_threads();
+					client.start();
+					// MyVncClient.main(clientSocket);
+					// echo.Interruption(clientSocket);
+					echoServer.close();
+				}
+
+			} catch (IOException e) {
 				System.out.println(e);
 			}
 			/*
-			try {
-				Thread.sleep(100);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-			*/
+			 * try { Thread.sleep(100); } catch (InterruptedException e) {
+			 * e.printStackTrace(); }
+			 */
 		}
 	}
 }
-