12
|
1 package jp.ac.u_ryukyu.treevnc.server;
|
11
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.io.PrintStream;
|
|
5 import java.net.Socket;
|
|
6
|
|
7 public class BroadCastProxy {
|
|
8 private String str;
|
|
9 private Socket socket = null;
|
|
10 private PrintStream os = null;
|
|
11 private int port = 8182;
|
|
12
|
|
13 public BroadCastProxy(String _str) {
|
|
14 str = _str;
|
|
15 }
|
|
16
|
|
17 void createSocket(String addr) {
|
|
18 while (true) {
|
|
19 try {
|
|
20 Thread.sleep(1000);
|
|
21 socket = new Socket(addr, port);
|
|
22 os = new PrintStream(socket.getOutputStream());
|
|
23 sendData();
|
|
24 os.close();
|
|
25 socket.close();
|
|
26 break;
|
|
27 } catch (IOException e) {
|
|
28 System.out.println("Connection faild");
|
|
29 continue;
|
|
30 } catch (InterruptedException e) {
|
|
31 e.printStackTrace();
|
|
32 }
|
|
33 }
|
|
34 }
|
|
35
|
|
36 void sendData() {
|
|
37 os.println(str);
|
|
38 }
|
|
39
|
|
40 }
|