Mercurial > hg > FederatedLinda
view src/fdl/test/TestMetaLinda.java @ 93:a1d796c0e975 fuchita
Wait Read Tester
author | one |
---|---|
date | Tue, 25 May 2010 22:57:54 +0900 |
parents | 82a292aa41ad |
children |
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.PSX; import fdl.PSXLinda; import fdl.PSXReply; /** * PSXLinda stream * * @author Shinji Kono * * @param localhost 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."); r = psx.in(1); for(int i=0;i<10;i++) { ByteBuffer data = ByteBuffer.allocate(10); data.putInt(i); data.flip(); psx.out(1,data); } for(int i=0;i<50;i++) { if (r.ready()) { System.err.println("Get:"+r.data.getInt()); r = psx.in(1); } // System.out.println("syncing..."+i); psx.sync(100); } System.out.println("Try to stop the server"); psx.out(PSX.META_STOP, null); psx.sync(100); } catch (IOException e) { System.err.println("Communication failure."); } } }