Annotation of OpenXM/src/OpenMath/testclient.java, Revision 1.1
1.1 ! tam 1: /**
! 2: * $OpenXM$
! 3: *
! 4: */
! 5:
! 6: import java.io.*;
! 7: import JP.ac.kobe_u.math.tam.OpenXM.*;
! 8:
! 9: final class testclient{
! 10: private OpenXM asir; // for debug
! 11:
! 12: public static String usage(){
! 13: return "\n";
! 14: }
! 15:
! 16: public static void main(String[] argv) throws IOException{
! 17: OpenXM asir;
! 18: String host = "localhost";
! 19: int CtrlPort = 1200,StreamPort = 1300;
! 20:
! 21: for(int i=0;i<argv.length;i++){
! 22: if(argv[i].equals("-h")){
! 23: System.out.print(usage());
! 24: System.exit(0);
! 25: }else if(argv[i].equals("-host")){
! 26: host = argv[++i];
! 27: }else if(argv[i].equals("-data")){
! 28: StreamPort = Integer.valueOf(argv[++i]).intValue();
! 29: }else if(argv[i].equals("-control")){
! 30: CtrlPort = Integer.valueOf(argv[++i]).intValue();
! 31: }else{
! 32: System.err.println("unknown option :"+ argv[i]);
! 33: System.exit(1);
! 34: }
! 35: }
! 36:
! 37: try{ // connect to server
! 38: asir = new OpenXM(host,CtrlPort,StreamPort);
! 39: }catch(java.net.UnknownHostException e){
! 40: System.err.println("host unknown.");
! 41: System.err.println(e.getMessage());
! 42: return;
! 43: }catch(IOException e){
! 44: System.err.println("connection failed.");
! 45: System.err.println("IOException occuer !!");
! 46: System.err.println(e.getMessage());
! 47: return;
! 48: }
! 49:
! 50: System.out.println("start");
! 51:
! 52: try{ // send data to server
! 53: asir.send(new SM(SM.SM_mathcap));
! 54: asir.send(new SM(SM.SM_popCMO));
! 55: asir.send(new CMO_ZZ("12345678901234567890"));
! 56: asir.send(new SM(SM.SM_popCMO));
! 57: }catch(NumberFormatException e){
! 58: System.err.println(e.getMessage());
! 59: }catch(MathcapViolation e){
! 60: System.err.println(e.getMessage());
! 61: }
! 62:
! 63: try{ // receive a data which come from server
! 64: while(true){
! 65: CMO tmp;
! 66:
! 67: switch(asir.receiveOXtag()){
! 68: case OpenXM.OX_COMMAND:
! 69: System.out.println("> "+ asir.receiveSM());
! 70: break;
! 71:
! 72: case OpenXM.OX_DATA:
! 73: tmp = asir.receiveCMO();
! 74: System.out.println("=> "+ tmp);
! 75: break;
! 76: }
! 77: }
! 78: }catch(IOException e){
! 79: e.printStackTrace();
! 80: }finally{
! 81: System.out.println("breaking...");
! 82: }
! 83: }
! 84: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>