Mercurial > hg > FederatedLinda
comparison src/fdl/test/TestMetaLinda.java @ 28:132c9bc28d6b
*** empty log message ***
author | kono |
---|---|
date | Wed, 20 Aug 2008 18:11:30 +0900 |
parents | |
children | 7a74d7396d65 |
comparison
equal
deleted
inserted
replaced
27:1acf423ffdcb | 28:132c9bc28d6b |
---|---|
1 /* | |
2 * @(#)TestMetaLinda.java 1.1 06/04/01 | |
3 * | |
4 * Copyright 2006 Shinji KONO | |
5 * | |
6 | |
7 Test PSX Lidna | |
8 | |
9 */ | |
10 | |
11 package fdl.test; | |
12 | |
13 import java.io.IOException; | |
14 import java.net.InetAddress; | |
15 import java.net.InetSocketAddress; | |
16 import java.net.UnknownHostException; | |
17 import java.nio.ByteBuffer; | |
18 | |
19 import fdl.FederatedLinda; | |
20 import fdl.PSXLinda; | |
21 import fdl.PSXReply; | |
22 import fdl.PSX; | |
23 | |
24 | |
25 /** | |
26 * PSXLinda stream | |
27 * | |
28 * @author Shinji Kono | |
29 * | |
30 * @param host The host to connect to | |
31 * @param port The port to connect to at the host | |
32 | |
33 */ | |
34 | |
35 | |
36 public class TestMetaLinda { | |
37 static int id; | |
38 public static void main (String args[]) { | |
39 | |
40 FederatedLinda fdl; | |
41 PSXLinda psx; | |
42 String host; | |
43 int port = 10000; | |
44 PSXReply r; | |
45 InetSocketAddress localAddress; | |
46 | |
47 | |
48 try { | |
49 localAddress = new InetSocketAddress(InetAddress.getLocalHost(), port); | |
50 host = localAddress.getHostName(); | |
51 } catch (UnknownHostException e) { | |
52 host = "localhost"; | |
53 } | |
54 | |
55 try { | |
56 fdl = FederatedLinda.init(); | |
57 psx = fdl.open(host,port); | |
58 System.out.println("Connected."); | |
59 | |
60 ByteBuffer data = ByteBuffer.allocate(10); | |
61 | |
62 for(int i=0;i<10;i++) { | |
63 data.clear(); | |
64 data.putInt(i); | |
65 data.flip(); | |
66 psx.out(1,data); | |
67 r = psx.in(1); | |
68 if (r.ready()) { | |
69 System.out.println("Get:"+r.data); | |
70 r = psx.in(1); | |
71 } | |
72 psx.sync(100); | |
73 } | |
74 | |
75 data.clear(); | |
76 psx.out(PSX.META_STOP, data); | |
77 psx.sync(); | |
78 | |
79 } catch (IOException e) { | |
80 System.err.println("Communication failure."); | |
81 } | |
82 } | |
83 | |
84 | |
85 } | |
86 |