Mercurial > hg > FederatedLinda
view src/fdl/TestPSXLinda.java @ 7:1809e2b05824
Initial revision
author | fuchita |
---|---|
date | Sat, 16 Feb 2008 13:12:52 +0900 |
parents | 083a0b5e12cc |
children | 0243987383b7 |
line wrap: on
line source
/* * @(#)TestPSXLinda.java 1.1 06/04/01 * * Copyright 2006 Shinji KONO * Test PSX Lidna */ package fdl; import java.io.IOException; import java.nio.ByteBuffer; /** * 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; PSXLinda 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); } }