Mercurial > hg > FederatedLinda
view src/fdl/test/TestPSXLinda.java @ 21:fac6e0073b1a meta-engine-written
*** empty log message ***
author | kono |
---|---|
date | Tue, 19 Aug 2008 10:48:22 +0900 |
parents | |
children | 56e015e8f5dc |
line wrap: on
line source
/* * @(#)TestPSXLinda.java 1.1 06/04/01 * * Copyright 2006 Shinji KONO * Test PSX Lidna */ package fdl.test; import java.io.IOException; import java.nio.ByteBuffer; import fdl.FederatedLinda; import fdl.PSXLindaInterface; import fdl.PSXReply; /** * PSXLinda stream * * @author Shinji Kono * * @param host The host to connect to * @param port The port to connect to at the host */ class TestPSXLinda { static int id; public static void main (String args[]) { FederatedLinda fdl; PSXLindaInterface psx; String host = "localhost"; int port = 10000; PSXReply r; // try { // port = Integer.parseInt(args[1]); // } catch (NumberFormatException nfex) { } try { fdl = FederatedLinda.init(); psx = fdl.open(host,port); r = psx.in(65535); //for(int i=0;i<100;i++) { //if (1==0) { //} fdl.sync(1); //} System.out.println("Connected."); ByteBuffer data = ByteBuffer.allocate(10); data.putInt(10); psx.out(1,data,4); while(!r.ready()) { psx.sync(1000); // System.out.println("Waiting...."); } } catch (IOException nfex) { nfex.printStackTrace(); System.out.println("Faild."); return; } print_id(r); } public static void print_id (PSXReply ans) { ByteBuffer r = ans.getData(); id = r.getShort(); System.out.print("ID = "); System.out.println(id); } }