com.sun.rpc
Class Rpc

java.lang.Object
  extended by com.sun.rpc.Rpc

public class Rpc
extends java.lang.Object

This class transmits and receives RPC calls to an RPC service at a specific host and port.

Author:
Brent Callaghan
See Also:
Connection, RpcException, MsgAcceptedException, MsgDeniedException

Field Summary
 Connection conn
           
 
Constructor Summary
Rpc(Connection conn, int prog, int vers)
          Construct a new Rpc object - equivalent to a "client handle" using an AUTH_NONE cred handle.
Rpc(Connection conn, int prog, int vers, Cred cr)
          Construct a new Rpc object - equivalent to a "client handle" using a given cred handle "cr"
Rpc(java.lang.String server, int port, int prog, int vers, java.lang.String proto, int maxReply)
          Construct a new Rpc object - equivalent to a "client handle"
 
Method Summary
 void delCred()
          Delete the RPC credential data and destroy its security context with the server.
 Cred getCred()
          Return the RPC credential
 java.net.InetAddress getPeer()
          Since this returns the address of the server it may seem redundant - but if you receive a reply to a broadcast RPC you need to know who is replying.
 Xdr rpc_call_one(Xdr call, byte[] arg, int timeout)
          Transmit the XDR call buffer containing an RPC header followed by a protocol header and receive the reply.
 Xdr rpc_call(Xdr call, int timeout, int retries)
          Make an RPC call but retry if necessary Retries use exponential backoff up to MAX_TIMEOUT ms.
 void rpc_header(Xdr call, int proc)
          Construct an RPC header in the XDR buffer
 void setCred(Cred c)
          Set the RPC credential
 void setRpcHandler(RpcHandler r)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

public Connection conn
Constructor Detail

Rpc

public Rpc(Connection conn,
           int prog,
           int vers)
Construct a new Rpc object - equivalent to a "client handle" using an AUTH_NONE cred handle.

Parameters:
conn - A connection to the server
prog - The program number of the service
vers - The version number of the service

Rpc

public Rpc(Connection conn,
           int prog,
           int vers,
           Cred cr)
Construct a new Rpc object - equivalent to a "client handle" using a given cred handle "cr"

Parameters:
conn - A connection to the server
prog - The program number of the service
vers - The version number of the service
cr - The cred to be used: CredUnix or CredGss

Rpc

public Rpc(java.lang.String server,
           int port,
           int prog,
           int vers,
           java.lang.String proto,
           int maxReply)
    throws java.io.IOException
Construct a new Rpc object - equivalent to a "client handle"

Parameters:
server - The hostname of the server
port - The port number for the service
prog - The program number of the service
vers - The version number of the service
proto - The protocol to be used: "tcp" or "udp"
maxReply - The maximum size of the RPC reply
Throws:
java.io.IOException - if an I/O error occurs
Method Detail

setCred

public void setCred(Cred c)
             throws RpcException
Set the RPC credential

Parameters:
c - - cred to be used
Throws:
RpcException

delCred

public void delCred()
             throws RpcException
Delete the RPC credential data and destroy its security context with the server.

Throws:
RpcException

getCred

public Cred getCred()
Return the RPC credential

Returns:
The credential

setRpcHandler

public void setRpcHandler(RpcHandler r)

rpc_header

public void rpc_header(Xdr call,
                       int proc)
                throws RpcException
Construct an RPC header in the XDR buffer

Parameters:
call - The XDR buffer for the header
proc - The service procedure to be called
Throws:
RpcException

rpc_call_one

public Xdr rpc_call_one(Xdr call,
                        byte[] arg,
                        int timeout)
                 throws java.io.IOException,
                        RpcException
Transmit the XDR call buffer containing an RPC header followed by a protocol header and receive the reply.

Parameters:
call - XDR buffer containing RPC call to transmit
arg - (seq_num + RPC argument) if wrap
timeout - after this number of milliseconds
Returns:
Xdr the XDR buffer for the reply
Throws:
RpcException
java.io.IOException

rpc_call

public Xdr rpc_call(Xdr call,
                    int timeout,
                    int retries)
             throws java.io.IOException
Make an RPC call but retry if necessary Retries use exponential backoff up to MAX_TIMEOUT ms. Note that we handle TCP connections differently: there is no timeout, and retransmission is used only when reconnecting.

Parameters:
call - XDR buffer containing RPC call to transmit
timeout - for the initial call
retries - the number of times to retry the call. A value of zero implies forever.
Returns:
Xdr the XDR buffer for the reply
Throws:
java.io.IOException

getPeer

public java.net.InetAddress getPeer()
Since this returns the address of the server it may seem redundant - but if you receive a reply to a broadcast RPC you need to know who is replying.

Returns:
address of the Peer