Mercurial > hg > Members > you > BroadCastTreeVNC
view src/treeVnc/GetBroadCastClient.java @ 5:970d5ac80256
add MyDataInputStream.java and DataInputStream1.java
author | one |
---|---|
date | Mon, 23 Apr 2012 21:10:23 +0900 |
parents | 756bfaf731f3 |
children |
line wrap: on
line source
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; } }