"showOnTranscript"
,
expecting a string argument, which is displayed on the transcript.
The range of ip-port numbers which the server uses is defined by the following method:
this lets the server process choose any free port in the given range.
Notice that clients of the server need not know the concrete port number, as
all rpc servers register themselfes at the portmapper.
The portmapper maps the programs number (as specified in its xdr definition) to
the port number on which the server sits.
portNumbers
^ #( 44400 to: 44499 )
Portmapper is usually already installed on your system (on all unix systems);
however, a smalltalk implementation of it is also part of the ST/X distribution.
The interface is defined in the classes xdr
method, which is defined
as:
Notice, that all RPC servers should provide the
xdr
^ '
typedef string stringArg<>;
program DEMO {
version DEMOVERS {
void
null(void) = 0;
boolean
showOnTranscript(stringArg) = 1;
} = 1;
} = 200199;
'
"null"
procedure,
which can be used for connectivity testing.
However, the programmer is not required to implement this method (it is inherited, from
the DemoServers superclass: RPCServer
.
The implementation of the showOnTranscript
is simple:
Thats all - the server is started by evaluating:
showOnTranscript:argVector
Transcript showCR:(argVector at:1).
^ true.
After that, you should find the server process in the ProcessMonitor, as it waits
for incoming connections.
SunRPC::DemoServer start
Also, you can should find the server registered in the portmapper,
by executing (on the shell level) the following command (as root on most systems) :
the programnumber (20199) should be in the list.
# rpcinfo -p
A smalltalk client is especially simple; only two methods are required to implement
a DemoClient: xdr
(on the class side) to define the interface, and
a call-wrapper.
The interface definitionis the same as the servers definition, therefore,
xdr
is defined in DemoClient as:
the call wrapper is:
xdr
^ DemoServer xdr
showOnTranscript:aString
|reply|
reply := self operation:#showOnTranscript argument:aString.
^ reply
Now, a client request can be sent with:
|demoClient|
demoClient := SunRPC::DemoClient toHost:'localhost'.
demoClient showOnTranscript:'hello world'.
Copyright © 2002 eXept Software AG
<info@exept.de>