view src/fdl/ComDebug_Client.java @ 5:4391c9fac885

fix parameter
author fuchita
date Sat, 16 Feb 2008 13:06:47 +0900
parents 2023d9b31af9
children 609b288f47f9
line wrap: on
line source

package fdl;


import java.io.IOException;
//import java.nio.ByteBuffer;
//import java.nio.CharBuffer;
import java.nio.CharBuffer;


public class ComDebug_Client implements PSXQueueInterface{

	static int id;
	static final boolean debug = false;

	public static void main(String[] args) {
		FederatedLinda fdl;
		PSXLinda psx;
		String host  = "localhost";
		int port = 10000;
		int connect_num = 1;
		final String usages = "usage: ComDebug_Client [-h host -p port]";

		//引数判定
		try {
			if (args.length < 2) {
				System.err.println(usages);
			}
				
			for (int i=0; i<args.length; ++i) {
				if("-h".equals(args[i])) {
					host = (String)(args[++i]);
					System.err.println("host = "+host);
				} else {
					//System.err.println(usages);
				}
				if("-p".equals(args[i])) {
					port = Integer.parseInt(args[++i]);
					System.err.println("port = "+port);
				} else {
					//System.err.println(usages);
				}
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		
		
		try {
			PSXReply r;
		    fdl = FederatedLinda.init();
		    psx = fdl.open(host,port);
		    r = psx.in(65535);
			fdl.sync(1);
			if(debug == true){
			    System.out.println("PSXReply =>"+r.toString());
		    }

		    System.out.println("COM_DEBUG Connected.["+host+":"+port+"]");
		    psx.in(PRIVILEGED_ID_START+connect_num);
		    connect_num++;
		    while(true) {
		    	fdl.sync_com(1000);
		    }
		} catch (IOException nfex) {
			nfex.printStackTrace();
		    System.out.println("Faild.");
		    return;
		}
	}
}