version 1.7, 2001/11/01 08:54:50 |
version 1.11, 2021/03/29 02:35:12 |
|
|
/** |
/** |
* $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java,v 1.6 2001/01/28 19:17:24 tam Exp $ |
* $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java,v 1.10 2002/10/27 10:39:32 takayama Exp $ |
*/ |
*/ |
package ORG.openxm.tam; |
package ORG.openxm.tam; |
|
|
Line 8 import java.net.*; |
|
Line 8 import java.net.*; |
|
|
|
|
|
/*&ja |
/*&ja |
OpenXM サーバとの接続を行なうクラス. |
OpenXM 泣若・膓茵. |
クライアント側が使用する. |
ゃ≪潟眼篏睡. |
接続するサーバ毎に一つの OpenXM クラスが必要. |
・膓泣若罸筝ゃ OpenXM 鴻綽荀. |
*/ |
*/ |
/** |
/** |
* OpenXM is a class to connect to OpenXM RFC100 compliant |
* OpenXM is a class to connect to OpenXM servers, |
* servers. |
* which are compliant to OpenXM RFC 100. |
* There is one-to-one correspondence between the instances |
* There is one-to-one correspondence between the instances |
* of the class OpenXM and the OpenXM servers. |
* of the class OpenXM and the OpenXM servers. |
*/ |
*/ |
Line 23 public class OpenXM{ |
|
Line 23 public class OpenXM{ |
|
final protected boolean debug = false; |
final protected boolean debug = false; |
|
|
/*&ja |
/*&ja |
* OpenXM サーバとの接続を TCP/IP ソケットを用いて行なう. |
* OpenXM 泣若・膓 TCP/IP 純宴茵. |
* マシン名 host のポート番号 CtrlPort にコントロールを, |
* 激喝 host 若 CtrlPort 潟潟若, |
* ポート番号 StreamPort にデータ用の接続を行なう. |
* 若 StreamPort 若睡・膓茵. |
*/ |
*/ |
/** |
/** |
* Connect to an OpenXM server via TCP/IP socket. |
* Connect to an OpenXM server via TCP/IP socket. |
* host : machine name of the OpenXM server. |
* @param host a machine name of the OpenXM server. |
* CtrlPort : control port number of the OpenXM server. |
* @param CtrlPort the control port number of the OpenXM server. |
* StreamPort : data port number of the OpenXM server. |
* @param StreamPort the data port number of the OpenXM server. |
* As to details on the notion of control port and data port, see |
* As to details on the notion of control port and data port, see |
* Design and Implementation of OpenXM client server model and |
* Design and Implementation of OpenXM client server model and |
* common mathematical object format (OpenXM-RFC 100, |
* common mathematical object format (OpenXM-RFC 100, |
* proposed standard) |
* proposed standard) |
* at http://www.openxm.org |
* @see <a href="http://www.openxm.org">OpenXM</a> |
*/ |
*/ |
public OpenXM(String host,int CtrlPort,int StreamPort) throws IOException{ |
public OpenXM(String host,int CtrlPort,int StreamPort) throws IOException{ |
control = new OpenXMstream(host,CtrlPort); |
control = new OpenXMstream(host,CtrlPort); |
Line 53 public class OpenXM{ |
|
Line 53 public class OpenXM{ |
|
stream.sendByteOrder(); |
stream.sendByteOrder(); |
} |
} |
|
|
|
/*&ja |
|
* 潟潟 command 腴> |
|
* OpenXM 泣若・膓 TCP/IP 純宴茵. |
|
* 激喝 host 若 CtrlPort 潟潟若, |
|
* 若 StreamPort 若睡・膓茵. |
|
*/ |
/** |
/** |
* コマンド command を立ち上げ、 |
* First, execute a command, which is usually an OpenXM server, |
* OpenXM サーバとの接続を TCP/IP ソケットを用いて行なう. |
* and next try to connect to the OpenXM server via TCP/IP. |
* マシン名 host のポート番号 CtrlPort にコントロールを, |
* @param command a command. |
* ポート番号 StreamPort にデータ用の接続を行なう. |
* @param host a machine name of the OpenXM server. |
|
* @param CtrlPort the control port number of the OpenXM server. |
|
* @param StreamPort the data port number of the OpenXM server. |
*/ |
*/ |
public OpenXM(String command,String host,int CtrlPort,int StreamPort) |
public OpenXM(String command,String host,int CtrlPort,int StreamPort) |
throws IOException{ |
throws IOException{ |
Line 76 public class OpenXM{ |
|
Line 84 public class OpenXM{ |
|
stream.sendByteOrder(); |
stream.sendByteOrder(); |
} |
} |
|
|
|
public OpenXM(String host,int CtrlPort,int StreamPort,String ox_server,int oxd_port,String pass) |
|
throws IOException{ |
|
// pass may be a null string. |
|
control = new OpenXMstream(host,CtrlPort,pass); |
|
stream = new OpenXMstream(host,StreamPort,pass); |
|
System.err.println("Listening..."); |
|
System.err.println("Launch ox server with the reverse option, e.g., ox -ox ox_asir -reverse"); |
|
// Launch ox_server by the oxd daemon (oxd_port). |
|
// BUG: It has not yet been implemented. |
|
control.OpenXMstreamAccept(); |
|
System.err.println("Accepted the control port."); |
|
stream.OpenXMstreamAccept(); |
|
System.err.println("Accepted the data port."); |
|
|
|
|
|
control.sendByteOrder(); |
|
stream.sendByteOrder(); |
|
} |
|
|
|
public OpenXM(String ox_server) throws IOException { |
|
int oxdPort = 8089; |
|
String host = "localhost"; |
|
oxdStream oxd = new oxdStream(oxdPort); |
|
int cport,dport; |
|
cport = oxd.startPhase1(); |
|
dport = cport+1; |
|
try { |
|
control = new OpenXMstream(host,cport,""); |
|
stream = new OpenXMstream(host,dport,""); |
|
}catch( IOException e) { |
|
System.err.println("Could not open ports for client."); |
|
oxd.write("<bye/>"); |
|
} |
|
|
|
System.err.println("Listenning..."); |
|
|
|
oxd.startPhase2(ox_server,cport); |
|
|
|
control.OpenXMstreamAccept(); |
|
System.err.println("Accepted the control port."); |
|
stream.OpenXMstreamAccept(); |
|
System.err.println("Accepted the data port."); |
|
|
|
|
|
control.sendByteOrder(); |
|
stream.sendByteOrder(); |
|
} |
|
|
|
|
|
/*&ja |
|
* 泣若荐膊筝茵. 憜絎茖. |
|
*/ |
/** |
/** |
* 接続の初期化を行なう. 現在は未実装. |
* Resetting the engine process. It has not yet been implemented. |
*/ |
*/ |
public synchronized void resetConnection(){ |
public synchronized void resetConnection(){ |
debug("control: stopping computer process..."); |
debug("control: stopping computer process..."); |
debug("control: sending SYNC BALL."); |
debug("control: sending SYNC BALL."); |
} |
} |
|
|
|
/*&ja |
|
* OpenXM <祉若吾若帥鴻若篆<. |
|
* <純<祉若吾cс. |
|
* т. |
|
*/ |
/** |
/** |
* OpenXM メッセージをデータストリームに送信する. |
* Send an OpenXM message object. |
* このメソッドはメッセージのボディの部分だけでよい. |
* @param object a message. For example, oxm.send(new CMO_STRING("Hello")) |
* ヘッダ部分は自動で付加される. |
* sends a string "Hello" to the OpenXM server oxm in the CMO_STRING data |
|
* encoding. |
*/ |
*/ |
public void send(OXbody object) throws IOException,MathcapViolation{ |
public void send(OXbody object) throws IOException,MathcapViolation{ |
stream.send(object); |
stream.send(object); |
} |
} |
|
|
|
/*&ja |
|
* 若帥鴻若 OpenXM <祉若吾. |
|
*/ |
/** |
/** |
* データストリームから OpenXM メッセージを受け取る. |
* Receive an OpenXM message. |
*/ |
*/ |
public OXmessage receive() throws IOException{ |
public OXmessage receive() throws IOException{ |
return stream.receive(); |
return stream.receive(); |
} |
} |
|
|
|
/*&ja |
|
* 若帥鴻若 MathCap mathcap 荐絎. |
|
* 篁ュ, 篆<吾с mathcap c |
|
* сャ. 絎сャ |
|
* OXbody 鴻羇丞鴻絎茖. |
|
* mathcap 吾с, |
|
* 篁ュ MathcapViolation 榊緇. |
|
*/ |
/** |
/** |
* データストリームの MathCap を mathcap に設定する. |
* Set the mathcap. |
* 以後, 送信するオブジェクトは mathcap に合っているかどうか |
* If one tries to send an object which is prohibited to send by the mathcap, |
* チェックが入る. 実際にチェックが入るかどうかは |
* the mathcapViolation exception is thrown. |
* OXbody クラスの派生クラスの実装による. |
|
* mathcap に反したオブジェクトを送ろうとした時には, |
|
* 以後 MathcapViolation が発生することが期待される. |
|
*/ |
*/ |
public void setMathCap(CMO_MATHCAP mathcap){ |
public void setMathCap(CMO_MATHCAP mathcap){ |
stream.setMathCap(mathcap); |
stream.setMathCap(mathcap); |
Line 158 public class OpenXM{ |
|
Line 232 public class OpenXM{ |
|
} |
} |
|
|
try{ |
try{ |
//サーバ側へ文字列を送信します。 |
//泣若眼御絖篆<障 |
ox.send(new SM(SM.SM_mathcap)); |
ox.send(new SM(SM.SM_mathcap)); |
ox.send(new SM(SM.SM_popString)); |
ox.send(new SM(SM.SM_popString)); |
|
|
Line 192 public class OpenXM{ |
|
Line 266 public class OpenXM{ |
|
|
|
//os.flush(); |
//os.flush(); |
|
|
//サーバ側から送信された文字列を受信します。 |
//泣若眼篆<絖篆<障 |
while(true){ |
while(true){ |
ox.receive(); |
ox.receive(); |
} |
} |