diff src/treeVnc/GetBroadCastClient.java @ 0:756bfaf731f3

create new repository
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Feb 2012 04:10:12 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/treeVnc/GetBroadCastClient.java	Tue Feb 21 04:10:12 2012 +0900
@@ -0,0 +1,81 @@
+package treeVnc;
+
+import java.io.BufferedReader;
+//import java.io.ByteArrayInputStream;
+//import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class GetBroadCastClient implements Runnable {
+	private ServerSocket server = null;
+	BufferedReader is;
+	private int port = 8182;
+	private boolean stopFlag = false;
+	TextBoxClient text = new TextBoxClient();
+	
+	private void getData() {
+		try {
+			server = new ServerSocket(port);
+			while(true) {
+				Socket socket = server.accept();  
+				is = new BufferedReader(new InputStreamReader(
+						socket.getInputStream()));
+				String line = is.readLine();
+				if(line!=null){
+					text.checkBox(line);
+				}
+				text.setButton();
+				text.visible();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	void socketClose() {
+		try {
+			text.unVisible();
+			//server.close(); after the modify
+			is.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+/*	
+	private int castInt(byte[] a) {
+		int value = 0;
+		ByteArrayInputStream bais = new ByteArrayInputStream(a);
+		DataInputStream dis = new DataInputStream(bais);
+		try {
+			value = dis.readInt();
+		} catch (IOException e) {
+		}
+		System.out.println(value);
+		return value;
+	}
+
+	private String castString(byte[] a) {
+		String recover = new String(a);
+		recover = recover.replace("¥n", "");
+		recover = recover.trim();
+		System.out.println(recover);
+		return recover;
+	}
+*/
+	
+	public void run() {
+		getData();
+	}
+
+	public void setStopFlag(boolean stopFlag) {
+		this.stopFlag = stopFlag;
+	}
+
+	public boolean isStopFlag() {
+		return stopFlag;
+	}
+
+}