com.distinct.rpc
Class JRPCClient

java.lang.Object
  |
  +--com.distinct.rpc.JRPCClient
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
rpcbcl, rpcbind, yp, YPBINDPROG, YPPUSH_XFRRESPPROG

public class JRPCClient
extends java.lang.Object
implements java.io.Serializable

From this class all Jrpcgen generated interfaces are derived. Basically it is a wrapper around a protocol object (derived from ClientGeneric). This can be either a ClientTCP or a ClientUDP object for a standard RPC protocol connection or a ClientHTTP object for an HTTP-tunneling connection.

See Also:
ClientGeneric, Serialized Form

Constructor Summary
JRPCClient(ClientGeneric protocol)
          Creates a RPC client and initializes it with a protocol client.
JRPCClient(java.net.InetAddress host, int prog, int vers, boolean stream)
          Creates a RPC client and connects it to a server.
JRPCClient(java.net.InetAddress host, int prog, int vers, int port, boolean stream)
          Creates a RPC client and connects it to a server with a known port.
 
Method Summary
static void BroadcastCall(int prog, int vers, int proc, XDRType in, XDRType out, BroadcastHandler eachcall)
          Calls all available servers by sending a broadcast message.
 void Call(int proc, XDRType in, XDRType out)
          Calls the server.
 void CloseClient()
          Closes the RPC client and frees the resources.
 ClientGeneric GetClient()
          Returns the protocol client.
 void SetClient(ClientGeneric protocol)
          Sets the protocol client.
 void SetResend(int milliseconds)
          Changes the timeout value for retransmission of the request (UDP only, default is 5 sec).
 void SetTimeout(int timeout)
          Changes the timeout value for waiting on server replies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRPCClient

public JRPCClient(java.net.InetAddress host,
                  int prog,
                  int vers,
                  boolean stream)
           throws RPCError
Creates a RPC client and connects it to a server. Calls the remote Portmapper in order to get the port of the server.

Parameters:
host - The host on which the server lives.
prog - The program ID of the server as defined in the .x IDL file.
vers - The program version of the server as defined in the .x IDL file.
stream - true for a TCP connection, false for UDP.
Throws:
RPCError - When the connection could not be established.

JRPCClient

public JRPCClient(java.net.InetAddress host,
                  int prog,
                  int vers,
                  int port,
                  boolean stream)
           throws RPCError
Creates a RPC client and connects it to a server with a known port. (No interaction with a portmapper)

Parameters:
host - The host on which the server lives.
prog - The program ID of the server as defined in the .x IDL file.
vers - The program version of the server as defined in the .x IDL file.
port - The port on which the server listens.
stream - true for a TCP connection, false for UDP.
Throws:
RPCError - When the connection could not be established.

JRPCClient

public JRPCClient(ClientGeneric protocol)
Creates a RPC client and initializes it with a protocol client.

Parameters:
protocol - The protocol object that implements the client connection.
Method Detail

Call

public void Call(int proc,
                 XDRType in,
                 XDRType out)
          throws RPCError,
                 java.io.IOException
Calls the server.

Parameters:
proc - The ID of the requested function.
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).
Throws:
java.io.IOException - When the call fails because the socket connetion fails.
RPCError - When the calls fails for any other reason.

BroadcastCall

public static void BroadcastCall(int prog,
                                 int vers,
                                 int proc,
                                 XDRType in,
                                 XDRType out,
                                 BroadcastHandler eachcall)
                          throws RPCError,
                                 java.io.IOException
Calls all available servers by sending a broadcast message. Calls are made indirectly via the portmapper's "CALLIT" interface. Only UDP calls are supported.

Parameters:
prog - The program ID of the server as defined in the .x IDL file.
vers - The program version of the server as defined in the .x IDL file.
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).
eachcall - The handler for all reply messages (null if the call should not wait for any reply).
Throws:
java.io.IOException - When the call fails because the socket connetion fails.
RPCError - When the calls fails for any other reason.

GetClient

public ClientGeneric GetClient()
Returns the protocol client.

Returns:
The protocol object.

SetClient

public void SetClient(ClientGeneric protocol)
Sets the protocol client.

Parameters:
protocol - The protocol object that implements the client connection.

CloseClient

public void CloseClient()
Closes the RPC client and frees the resources.


SetTimeout

public void SetTimeout(int timeout)
Changes the timeout value for waiting on server replies.

Parameters:
timeout - The new timeout value in ms (0 means no timeout at all, -1 means immediate return).

SetResend

public void SetResend(int milliseconds)
Changes the timeout value for retransmission of the request (UDP only, default is 5 sec).

Parameters:
milliseconds - The new timeout value in ms.