module Rpc_portmapper:Portmapper version 2sig
..end
The task of the portmapper is to map program numbers to port numbers. A RPC service that should be available in the whole network should:
set
procedure to establish a mapping of the
own program number to the port that has been allocated previouslyunset
procedure to remove the mapping
(this is NEVER done automatically!)getport
to find out the port where the
service is actually listening.type
t
val create : Rpc_client.connector -> t
val create_inet : string -> t
val shut_down : t -> unit
val null : t -> unit
val set : t ->
Rtypes.uint4 -> Rtypes.uint4 -> Rpc.protocol -> int -> bool
set pm_client program_nr version_nr protocol port_nr
:
Extends the mapping managed by the portmapper: The triple
(program_nr, version_nr, protocol)
is mapped to the given
port_nr
.
It is not allowed to overwrite an existing mapping.
The procedure returns true
if the mapping has been extended
and false
otherwise.
Note that it usually only possible to set
a mapping on the local
host.val unset : t ->
Rtypes.uint4 -> Rtypes.uint4 -> Rpc.protocol -> int -> bool
unset pm_client program_nr version_nr protocol port_nr
:
removes the mapping.
The procedure returns true
if the mapping has been removed
and false
otherwise.
Note that it usually only possible to unset
a mapping on the local
host.val getport : t -> Rtypes.uint4 -> Rtypes.uint4 -> Rpc.protocol -> int
getport pm_client program_nr version_nr protocol
:
finds out the port where the given service runs. Returns 0 if the
service is not registered.val dump : t -> (Rtypes.uint4 * Rtypes.uint4 * Rpc.protocol * int) list
(program_nr, version_nr, protocol, port)
val callit : t ->
Rpc_program.t -> string -> Xdr.xdr_value -> int * Xdr.xdr_value
callit pm_client program_spec proc_name argument
:
This is an alternate way of calling a remote procedure. Instead
of directly invoking the procedure, the portmapper does it for you.
You must pass a program specification, the procedure name and the
argument to callit
. On return, you get the port of the service
and the result of the procedure invocation.
Note that there are several disadvantages:
callit
gets a timeout in this case.callit
for indirecting calls.
The callit
interface was designed for broadcasts and should only
be used for this purpose.
This implementation of a callit
client cannot be used for
broadcasts, however.val port_of_program : Rpc_program.t -> string -> Rpc.protocol -> int
port_of_program program host protocol
:
queries the portmapper running on host
for the program
registered
for protocol
.
Returns the port number or fails if the number is not known.