114
|
1 package fdl.old.test.metaTransfer;
|
52
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.nio.ByteBuffer;
|
|
5
|
|
6 import fdl.FederatedLinda;
|
|
7 import fdl.PSXLinda;
|
|
8
|
|
9 public class TestSend extends Thread {
|
|
10 PSXLinda psxsend;
|
|
11 FederatedLinda fdlsend;
|
|
12
|
|
13 public void run(){
|
|
14 int id = 10;
|
|
15 int port = 10001;
|
53
|
16 boolean connect = true;
|
52
|
17 String host = "127.0.0.1";
|
|
18 ByteBuffer send = ByteBuffer.allocate(1024);
|
|
19 send.putInt(12);
|
|
20 send.flip();
|
53
|
21 while(connect){
|
|
22 try {
|
|
23 sendData(id, port, host, send);
|
|
24 connect = false;
|
|
25 } catch(IOException e) {
|
|
26 try {
|
|
27 Thread.sleep(40);
|
|
28 } catch (InterruptedException e1) {
|
|
29 e1.printStackTrace();
|
|
30 }
|
|
31 }
|
|
32
|
|
33 }
|
|
34 }
|
|
35
|
|
36 private void sendData(int id, int port, String host, ByteBuffer send) throws IOException {
|
52
|
37 fdlsend = FederatedLinda.init();
|
53
|
38
|
52
|
39 psxsend = fdlsend.open(host,port);
|
|
40 System.out.println("Connect Host1");
|
|
41 psxsend.out(id, send);
|
|
42 fdlsend.sync(1);
|
|
43 System.out.println("Send Data");
|
53
|
44
|
52
|
45 }
|
|
46
|
|
47 }
|