[BACK]Return to testclientr.java CVS log [TXT][DIR] Up to [local] / OpenXM / src / OpenMath

Annotation of OpenXM/src/OpenMath/testclientr.java, Revision 1.2

1.1       takayama    1: /**
1.2     ! takayama    2:  * $OpenXM: OpenXM/src/OpenMath/testclientr.java,v 1.1 2002/10/23 08:40:16 takayama Exp $
1.1       takayama    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
1.2     ! takayama   38:                // asir = new OpenXM(host,CtrlPort,StreamPort,"ox_asir",8089,"");
        !            39:                asir = new OpenXM("ox_asir");
1.1       takayama   40:     }catch(java.net.UnknownHostException e){
                     41:       System.err.println("host unknown.");
                     42:       System.err.println(e.getMessage());
                     43:       return;
                     44:     }catch(IOException e){
                     45:       System.err.println("connection failed.");
                     46:       System.err.println("IOException occuer !!");
                     47:       System.err.println(e.getMessage());
                     48:       return;
                     49:     }
                     50:
                     51:     System.err.println("start");
                     52:
                     53:     try{ // send data to server
                     54:       asir.send(new SM(SM.SM_mathcap));
                     55:       asir.send(new SM(SM.SM_popCMO));
                     56:       asir.send(new CMO_ZZ("12345678901234567890"));
                     57:       asir.send(new SM(SM.SM_popCMO));
                     58:     }catch(NumberFormatException e){
                     59:       System.err.println(e.getMessage());
                     60:     }catch(MathcapViolation e){
                     61:       System.err.println(e.getMessage());
                     62:     }
                     63:
                     64:     try{ // receive a data which come from server
                     65:       while(true){
                     66:        OXmessage message = asir.receive();
                     67:
                     68:        switch(message.getTag()){
                     69:        case OXmessage.OX_COMMAND:
                     70:           System.err.println("SM> "+ message.getBody());
                     71:           break;
                     72:
                     73:        case OXmessage.OX_DATA:
                     74:          System.err.println("CMO> "+ message.getBody());
                     75:           break;
                     76:        }
                     77:       }
                     78:     }catch(IOException e){
                     79:       e.printStackTrace();
                     80:     }finally{
                     81:       System.err.println("breaking...");
                     82:     }
                     83:   }
                     84: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>