Annotation of OpenXM_contrib2/asir2000/lib/launch, Revision 1.1.1.1
1.1 noro 1: /* $OpenXM: OpenXM/src/asir99/lib/launch,v 1.2 1999/11/15 08:59:10 noro Exp $ */
2: /*
3: usage of
4:
5: generate_port()
6: try_bind_listen()
7: try_connect()
8: try_accept()
9: register_server()
10: */
11:
12: def local_launch(Server,Use_X,Conn_To_Server,Use_Unix)
13: {
14: Host = Use_Unix ? "." : "127.1";
15: Display = getenv("DISPLAY");
16: if ( !Display )
17: Display = "0";
18: do {
19: Control_Sock = -1;
20: Server_Sock = -1;
21: do {
22: Control_Port = generate_port(Use_Unix);
23: Server_Port = generate_port(Use_Unix);
24: if ( !Conn_To_Server ) {
25: if ( Control_Sock < 0 )
26: Control_Sock = try_bind_listen(Control_Port);
27: if ( Server_Sock < 0 )
28: Server_Sock = try_bind_listen(Server_Port);
29: } else
30: break;
31: } while ( Control_Sock < 0 || Server_Sock < 0 );
32: ServerCmd = get_rootdir()+"/ox_launch"
33: +" "+Host
34: +" "+rtostr(Conn_To_Server) +" "+rtostr(Control_Port)
35: +" "+rtostr(Server_Port) +" "+Server +" "+Display;
36: if ( Use_X && getenv("DISPLAY") )
37: Cmd = "xterm -name ox_xterm -display "+Display
38: +" -geometry 60x10 -e "
39: + ServerCmd+"\&";
40: else
41: Cmd =ServerCmd+"\&";
42: shell(Cmd);
43: if ( Conn_To_Server ) {
44: Control_Sock = try_connect(Host,Control_Port);
45: Server_Sock = try_connect(Host,Server_Port);
46: } else {
47: Control_Sock = try_accept(Control_Sock,Control_Port);
48: Server_Sock = try_accept(Server_Sock,Control_Port);
49: }
50: } while ( Control_Sock < 0 || Server_Sock < 0 );
51: return register_server(Control_Sock,Control_Port,Server_Sock,Server_Port);
52: }
53:
54: def remote_launch(Host,Server,Use_X,Conn_To_Server)
55: {
56: Display = getenv("DISPLAY");
57: if ( !Display )
58: Display = "0";
59: do {
60: Control_Sock = -1;
61: Server_Sock = -1;
62: do {
63: Control_Port = generate_port();
64: Server_Port = generate_port();
65: if ( !Conn_To_Server ) {
66: if ( Control_Sock < 0 )
67: Control_Sock = try_bind_listen(Control_Port);
68: if ( Server_Sock < 0 )
69: Server_Sock = try_bind_listen(Server_Port);
70: } else
71: break;
72: } while ( Control_Sock < 0 || Server_Sock < 0 );
73: ServerCmd = get_rootdir()+"/ox_launch"
74: +" "+Host
75: +" "+rtostr(Conn_To_Server) +" "+rtostr(Control_Port)
76: +" "+rtostr(Server_Port) +" "+Server +" "+Display;
77: if ( Use_X && getenv("DISPLAY") )
78: Cmd = "xterm -name ox_xterm -display "+Display
79: +" -geometry 60x10 -e "
80: + ServerCmd+">&/dev/null&";
81: else
82: Cmd =ServerCmd+">&/dev/null&";
83: shell("rsh -n "+Host+" \""+Cmd+"\""+">/dev/null");
84: if ( Conn_To_Server ) {
85: Control_Sock = try_connect(Host,Control_Port);
86: Server_Sock = try_connect(Host,Server_Port);
87: } else {
88: Control_Sock = try_accept(Control_Sock,Control_Port);
89: Server_Sock = try_accept(Server_Sock,Control_Port);
90: }
91: } while ( Control_Sock < 0 || Server_Sock < 0 );
92: return register_server(Control_Sock,Control_Port,Server_Sock,Server_Port);
93: }
94: end$
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>