Mercurial > hg > FederatedLinda
view src/fdl/test/TestMetaLinda.java @ 29:7a74d7396d65
*** empty log message ***
author | kono |
---|---|
date | Thu, 21 Aug 2008 10:04:21 +0900 |
parents | 132c9bc28d6b |
children | 64071f8e2e0d |
line wrap: on
line source
/* * @(#)TestMetaLinda.java 1.1 06/04/01 * * Copyright 2006 Shinji KONO * Test PSX Lidna */ package fdl.test; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; import fdl.FederatedLinda; import fdl.PSXLinda; import fdl.PSXReply; import fdl.PSX; /** * PSXLinda stream * * @author Shinji Kono * * @param host The host to connect to * @param port The port to connect to at the host */ public class TestMetaLinda { static int id; public static void main (String args[]) { FederatedLinda fdl; PSXLinda psx; String host; int port = 10000; PSXReply r; InetSocketAddress localAddress; try { localAddress = new InetSocketAddress(InetAddress.getLocalHost(), port); host = localAddress.getHostName(); } catch (UnknownHostException e) { host = "localhost"; } try { fdl = FederatedLinda.init(); psx = fdl.open(host,port); System.out.println("Connected."); ByteBuffer data = ByteBuffer.allocate(10); r = psx.in(1); for(int i=0;i<10;i++) { data.clear(); data.putInt(i); data.flip(); psx.out(1,data); if (r.ready()) { System.err.println("Get:"+r.data.getInt()); r = psx.in(1); } psx.sync(100); } data.clear(); psx.out(PSX.META_STOP, data); psx.sync(); } catch (IOException e) { System.err.println("Communication failure."); } } }