view src/myVncClient/WaitReply.java @ 101:2f2f8da71d60

merge
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Mon, 24 Oct 2011 23:34:32 +0900
parents 961a5915834f 1d1bb77d871b
children
line wrap: on
line source

package myVncClient;

import java.net.*;
import java.io.*;

public class WaitReply extends Thread {
	// MyVncClient client;
	InterfaceForViewer client;
	private String treenum;
	boolean passflag;
	

	/*
	 * public WaitReply(String treenum,MyVncClient client) { this.client =
	 * client; this.treenum = treenum; }
	 */

	public WaitReply(String treenum, InterfaceForViewer client) {
		this.client = client;
		this.treenum = treenum;
	}
	
	public boolean checkPath() {
		return passflag;
	}
	
	public void run() {
		Socket clientSocket = null;
		ServerSocket echoServer = null;
		// boolean mainFlag;

		while (true) {
			try {
				echoServer = new ServerSocket(10001 + Integer.parseInt(treenum));
			} catch (IOException e) {
				System.out.println(e);
			}
			try {
				clientSocket = echoServer.accept();
				if (clientSocket != null) {
					client.close();
					passflag = true;
					// client.clientSocket = clientSocket;
					client.setClientSocket(clientSocket);
					client.init();
					client.setEchoValue(null);
					client.getParentName();
					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(); }
			 */
		}
	}
}