com.distinct.rpc
Class Pmap

java.lang.Object
  |
  +--com.distinct.rpc.Pmap
All Implemented Interfaces:
java.io.Serializable, XDRType

public class Pmap
extends java.lang.Object
implements XDRType

Interface to the portmapper.

See Also:
Serialized Form

Field Summary
static int PMAPPORT
           
static int PMAPPROC_CALLIT
           
static int PMAPPROC_DUMP
           
static int PMAPPROC_GETPORT
           
static int PMAPPROC_NULL
           
static int PMAPPROC_SET
           
static int PMAPPROC_UNSET
           
static int PMAPPROG
           
static int PMAPVERS
           
static int PMAPVERS_ORIG
           
static int PMAPVERS_PROTO
           
static int TRANSIENT_RANGE
           
 
Constructor Summary
Pmap()
           
Pmap(int progp, int versp, int protp, int portp)
          Creates a portmapper entry.
 
Method Summary
 int getPort(java.net.InetAddress host)
          Requests the portnumber of an entry in the portmapper of a given host and sets the portnumber of the server in the Pmap object.
static int getTransient(int vers, int port, boolean stream)
          Contacts the local Portmapper to register a transient callback server.
 int indirectCall(java.net.InetAddress host, int proc, XDRType in, XDRType out, int timeout)
          Calls a server via RPCBind's INDIRECT interface (and also sets the portnumber of the server in the Pmap object).
 int remoteCall(java.net.InetAddress host, int proc, XDRType in, XDRType out, int timeout)
          Calls a server via the Portmapper's CALLIT interface (and also sets the portnumber of the server in the Pmap object).
 boolean set(java.net.InetAddress host)
          Registeres an entry in the portmapper of a given host.
This method creates a temporary UDP client for calling the portmapper.
 boolean unset(java.net.InetAddress host)
          Unregisteres an entry in the portmapper of a given host.
 void xdr_decode(XDRStream xdrs)
          Decodes a portmapper entry in compliance to RFC 1832 (XDR).
 void xdr_encode(XDRStream xdrs)
          Encodes a portmapper entry in compliance to RFC 1832 (XDR).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PMAPPORT

public static final int PMAPPORT

PMAPPROG

public static final int PMAPPROG

PMAPVERS

public static final int PMAPVERS

PMAPVERS_PROTO

public static final int PMAPVERS_PROTO

PMAPVERS_ORIG

public static final int PMAPVERS_ORIG

PMAPPROC_NULL

public static final int PMAPPROC_NULL

PMAPPROC_SET

public static final int PMAPPROC_SET

PMAPPROC_UNSET

public static final int PMAPPROC_UNSET

PMAPPROC_GETPORT

public static final int PMAPPROC_GETPORT

PMAPPROC_DUMP

public static final int PMAPPROC_DUMP

PMAPPROC_CALLIT

public static final int PMAPPROC_CALLIT

TRANSIENT_RANGE

public static final int TRANSIENT_RANGE
Constructor Detail

Pmap

public Pmap()

Pmap

public Pmap(int progp,
            int versp,
            int protp,
            int portp)
Creates a portmapper entry.
Parameters:
progp - The program ID.
versp - The version of the program.
protp - The protocol identifier (JRPC.kIPPROTO_TCP or JRPC.kIPPROTO_UDP).
portp - The port number.
Method Detail

xdr_encode

public void xdr_encode(XDRStream xdrs)
Encodes a portmapper entry in compliance to RFC 1832 (XDR).
Specified by:
xdr_encode in interface XDRType
Parameters:
xdrs - The XDR output stream.

xdr_decode

public void xdr_decode(XDRStream xdrs)
                throws RPCError
Decodes a portmapper entry in compliance to RFC 1832 (XDR).
Specified by:
xdr_decode in interface XDRType
Parameters:
xdrs - The XDR input stream.

set

public boolean set(java.net.InetAddress host)
Registeres an entry in the portmapper of a given host.
This method creates a temporary UDP client for calling the portmapper.
Parameters:
host - The host where the portmapper lives.
Returns:
true on success

unset

public boolean unset(java.net.InetAddress host)
Unregisteres an entry in the portmapper of a given host. This method creates a temporary UDP client for calling the portmapper.
Parameters:
host - The host where the portmapper lives.
Returns:
true on success

getPort

public int getPort(java.net.InetAddress host)
Requests the portnumber of an entry in the portmapper of a given host and sets the portnumber of the server in the Pmap object. This method creates a temporary UDP client for calling the portmapper.
Parameters:
host - The host where the portmapper lives.
Returns:
The port number on success, 0 on error.

remoteCall

public int remoteCall(java.net.InetAddress host,
                      int proc,
                      XDRType in,
                      XDRType out,
                      int timeout)
               throws RPCError,
                      java.io.IOException
Calls a server via the Portmapper's CALLIT interface (and also sets the portnumber of the server in the Pmap object). This method creates a temporary UDP client for calling the portmapper. In case of any error at the remote site, the Portmapper sends no reply at all (only the timeout will terminate the call).
Parameters:
host - The host where the portmapper lives.
proc - The ID of the request function as defined in the .x IDL file.
in - The input parameter (as it has to be marshalled it must be derived from XDRType).
out - The output parameter (as it has to be marshalled it must be derived from XDRType).
timeout - The timeout value for this call in ms (0 means no timeout at all, -1 means immediate return).
Returns:
The port number on success, 0 on error.
Throws:
java.io.IOException - When the call fails because the socket connetion fails.
RPCError - When the calls fails for any other reason.

indirectCall

public int indirectCall(java.net.InetAddress host,
                        int proc,
                        XDRType in,
                        XDRType out,
                        int timeout)
                 throws RPCError,
                        java.io.IOException
Calls a server via RPCBind's INDIRECT interface (and also sets the portnumber of the server in the Pmap object). This method creates a temporary UDP client for calling RPCBind. In case of an error at the remote site, RPCBind reports back an error-code.
Parameters:
host - The host where the portmapper lives.
proc - The ID of the request function as defined in the .x IDL file.
in - The input parameter (as it has to be marshalled it must be derived from XDRType).
out - The output parameter (as it has to be marshalled it must be derived from XDRType).
timeout - The timeout value for this call in ms (0 means no timeout at all, -1 means immediate return).
Returns:
The port number on success, 0 on error.
Throws:
java.io.IOException - When the call fails because the socket connetion fails.
RPCError - When the calls fails for any other reason.

getTransient

public static int getTransient(int vers,
                               int port,
                               boolean stream)
Contacts the local Portmapper to register a transient callback server. It generates a random transient program number that is returned by the call.
Parameters:
vers - A version number of the program of the callback server.
port - The port on which the callback server waits for requests.
stream - true for a TCP server, false for UDP.
Returns:
Program number of the registered transient callback server, 0 on error.