0
|
1 package treeVnc;
|
|
2
|
|
3 import java.io.BufferedReader;
|
|
4 //import java.io.ByteArrayInputStream;
|
|
5 //import java.io.DataInputStream;
|
|
6 import java.io.IOException;
|
|
7 import java.io.InputStreamReader;
|
|
8 import java.net.ServerSocket;
|
|
9 import java.net.Socket;
|
|
10
|
|
11 public class GetBroadCastClient implements Runnable {
|
|
12 private ServerSocket server = null;
|
|
13 BufferedReader is;
|
|
14 private int port = 8182;
|
|
15 private boolean stopFlag = false;
|
|
16 TextBoxClient text = new TextBoxClient();
|
|
17
|
|
18 private void getData() {
|
|
19 try {
|
|
20 server = new ServerSocket(port);
|
|
21 while(true) {
|
|
22 Socket socket = server.accept();
|
|
23 is = new BufferedReader(new InputStreamReader(
|
|
24 socket.getInputStream()));
|
|
25 String line = is.readLine();
|
|
26 if(line!=null){
|
|
27 text.checkBox(line);
|
|
28 }
|
|
29 text.setButton();
|
|
30 text.visible();
|
|
31 }
|
|
32 } catch (IOException e) {
|
|
33 e.printStackTrace();
|
|
34 }
|
|
35 }
|
|
36
|
|
37 void socketClose() {
|
|
38 try {
|
|
39 text.unVisible();
|
|
40 //server.close(); after the modify
|
|
41 is.close();
|
|
42 } catch (IOException e) {
|
|
43 e.printStackTrace();
|
|
44 }
|
|
45 }
|
|
46
|
|
47 /*
|
|
48 private int castInt(byte[] a) {
|
|
49 int value = 0;
|
|
50 ByteArrayInputStream bais = new ByteArrayInputStream(a);
|
|
51 DataInputStream dis = new DataInputStream(bais);
|
|
52 try {
|
|
53 value = dis.readInt();
|
|
54 } catch (IOException e) {
|
|
55 }
|
|
56 System.out.println(value);
|
|
57 return value;
|
|
58 }
|
|
59
|
|
60 private String castString(byte[] a) {
|
|
61 String recover = new String(a);
|
|
62 recover = recover.replace("¥n", "");
|
|
63 recover = recover.trim();
|
|
64 System.out.println(recover);
|
|
65 return recover;
|
|
66 }
|
|
67 */
|
|
68
|
|
69 public void run() {
|
|
70 getData();
|
|
71 }
|
|
72
|
|
73 public void setStopFlag(boolean stopFlag) {
|
|
74 this.stopFlag = stopFlag;
|
|
75 }
|
|
76
|
|
77 public boolean isStopFlag() {
|
|
78 return stopFlag;
|
|
79 }
|
|
80
|
|
81 }
|