Annotation of OpenXM/src/OpenMath/testclientr.java, Revision 1.1
1.1 ! takayama 1: /**
! 2: * $OpenXM$
! 3: *
! 4: */
! 5:
! 6: import java.io.*;
! 7: import ORG.openxm.tam.*;
! 8:
! 9: final class testclientr{
! 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.err.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,"ox_asir",8089,"");
! 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.err.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: OXmessage message = asir.receive();
! 66:
! 67: switch(message.getTag()){
! 68: case OXmessage.OX_COMMAND:
! 69: System.err.println("SM> "+ message.getBody());
! 70: break;
! 71:
! 72: case OXmessage.OX_DATA:
! 73: System.err.println("CMO> "+ message.getBody());
! 74: break;
! 75: }
! 76: }
! 77: }catch(IOException e){
! 78: e.printStackTrace();
! 79: }finally{
! 80: System.err.println("breaking...");
! 81: }
! 82: }
! 83: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>