/** * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java,v 1.1 2000/09/07 10:41:34 tam Exp $ */ package ORG.openxm.tam; import java.io.*; import java.net.*; /** * OpenXM サーバとの接続を行なう抽象クラス * クライアント側が使用する. */ public class OpenXM{ private OpenXMconnection control = null, stream = null; final protected boolean debug = false; public OpenXM(String host,int CtrlPort,int StreamPort) throws IOException{ control = new OpenXMconnection(host,CtrlPort); try{ Thread.sleep(100); // We need a few wait for starting up server. }catch(InterruptedException e){ System.err.println(e.getMessage()); } stream = new OpenXMconnection(host,StreamPort); control.sendByteOrder(); stream.sendByteOrder(); } /** * 接続の reset を行なう. 現在は未実装. */ public synchronized void resetConnection(){ debug("control: stopping computer process..."); debug("control: sending SYNC BALL."); } /** * OpenXM メッセージを送信する. ただし、このメソッドは * ボディの部分だけでよい. ヘッダの部分は自動で付加される. public void send(OXbody object) throws IOException,MathcapViolation{ stream.send(object); } /** * OpenXM メッセージを受け取る. */ public OXmessage receive() throws IOException{ return stream.receive(); } /** * MathCap を mathcap に設定する. * 以後, mathcap に反した CMO を送ると * MathcapViolation が発生する. */ public void setMathCap(CMO_MATHCAP mathcap){ stream.setMathCap(mathcap); } private final void debug(String str){ if(debug){ System.err.println(str); } } public static void main(String[] argv){ String hostname = "localhost"; int ControlPort = 1200, DataPort = 1300; Runnable process = null; Thread thread; OpenXM ox; for(int i=0;i