SunRPCTest.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Chauser, January 7, 1992 10:44 am PST
~
BEGIN
client: SunRPC.Handle;
conversation: SunRPCAuth.Conversation;
server: SunRPCOnNetworkStream.Server;
serverAddress: Rope.ROPE;
pgm: CARD ~ 123456;
version: CARD ~ 10245;
nullProc: CARD ~ 0;
echoProc: CARD ~ 1;
StartTCPServer:
PROC []
RETURNS [UXStrings.CString] ~ {
server ¬ SunRPCOnNetworkStream.CreateServer[pgm, version, IServe, $ARPA, NIL, NIL];
serverAddress ¬ SunRPCOnNetworkStream.GetServerAddress[server].local;
RETURN [UXStrings.Create[serverAddress]];
};
StopServer:
PROC []
RETURNS [] ~ {
SunRPC.DestroyServer[server];
};
udpserverport: SunRPCOnUDP.Port;
StartUDPServer:
PROC []
RETURNS [UXStrings.CString] ~ {
server ¬ SunRPCOnUDP.CreateServer[pgm, version, IServe];
udpserverport ¬ SunRPCOnUDP.GetServerPort[server];
RETURN [UXStrings.Create[Convert.RopeFromCard[LOOPHOLE[udpserverport]]]];
};
IServe: SunRPC.ServerProc ~ {
SELECT proc
FROM
0 => {
h.StartReply[];
RETURN[TRUE, 10];
};
1 => {
text: Rope.ROPE ¬ h.GetRope[];
h.StartReply[];
h.PutRope[text];
RETURN[TRUE, 10];
};
ENDCASE => RETURN[FALSE, 10];
};
LocalTCP:
PROC []
RETURNS [] ~ {
client ¬ SunRPCOnNetworkStream.Create[$ARPA, serverAddress];
conversation ¬ SunRPCAuth.Initiate[myName: "Chauser"];
};
LocalUDP:
PROC []
RETURNS [] ~ {
client ¬ SunRPCOnUDP.Create[remotePort~udpserverport];
conversation ¬ SunRPCAuth.Initiate[myName: "Chauser"];
};
RemoteTCP:
PROC [address: UXStrings.CString]
RETURNS [] ~ {
client ¬ SunRPCOnNetworkStream.Create[$ARPA, UXStrings.ToRope[address, 100]];
conversation ¬ SunRPCAuth.Initiate[myName: "Chauser"];
};
RemoteUDP:
PROC [address: UXStrings.CString, port: SunRPCOnUDP.Port]
RETURNS [] ~ {
client ¬ SunRPCOnUDP.Create[Convert.ArpaAddressFromRope[UXStrings.ToRope[address, 100]], port];
conversation ¬ SunRPCAuth.Initiate[myName: "Chauser"];
};
ReleaseClient:
PROC []
RETURNS [] ~ {
SunRPC.Destroy[client];
};
CallNullProc:
PROC []
RETURNS [] ~ {
client.StartCall[conversation, pgm, version, nullProc];
client.SendCallAndReceiveReply[];
};
CallNull100:
PROC []
RETURNS [] ~ {
FOR i:
INT IN [0..100)
DO
client.StartCall[conversation, pgm, version, nullProc];
client.SendCallAndReceiveReply[];
ENDLOOP;
};
CallNullN:
PROC [n:
INT]
RETURNS [] ~ {
FOR i:
INT IN [0..n)
DO
client.StartCall[conversation, pgm, version, nullProc];
client.SendCallAndReceiveReply[500, 5];
ENDLOOP;
};
CallEchoProc:
PROC[]
RETURNS [Rope.
ROPE] ~ {
client.StartCall[conversation, pgm, version, echoProc];
client.PutRope["Test Message"];
client.SendCallAndReceiveReply[];
RETURN[client.GetRope[]];
};
CallPMap0:
PROC[] ~ {
client.StartCall[conversation, 100000, 2, 0];
client.SendCallAndReceiveReply[];
RETURN[];
};
CallPMap0N:
PROC[n:
INT] ~ {
FOR i:
INT IN [0..n)
DO
client.StartCall[conversation, 100000, 2, 0];
client.SendCallAndReceiveReply[];
ENDLOOP;
RETURN[];
};
DumpPMap:
PROC[]
RETURNS [UXStrings.CString] ~ {
result: Rope.ROPE;
client.StartCall[conversation, 100000, 2, 4];
client.SendCallAndReceiveReply[];
DO
more: CARD;
IF (more ¬ client.GetCard32[]) = 0 THEN EXIT;
result ¬ result.Cat[Convert.RopeFromCard[client.GetCard32[]], " " ]; -- program
result ¬ result.Cat[Convert.RopeFromCard[client.GetCard32[]], " " ]; -- version
result ¬ result.Cat[Convert.RopeFromCard[client.GetCard32[]], " " ]; -- protocol
result ¬ result.Cat[Convert.RopeFromCard[client.GetCard32[]], "\n " ]; -- port
ENDLOOP;
RETURN[ UXStrings.Create[result] ];
};