public class OncRpcTcpServerTransport extends OncRpcServerTransport
OncRpcTcpServerTransport
encapsulate
TCP/IP-based XDR streams of ONC/RPC servers. This server transport class
is responsible for accepting new ONC/RPC connections over TCP/IP.OncRpcServerTransport
,
OncRpcTcpConnectionServerTransport
,
OncRpcUdpServerTransport
Modifier and Type | Field and Description |
---|---|
protected int |
transmissionTimeout
Timeout during the phase where data is received within calls, or data is
sent within replies.
|
dispatcher, info, port
Constructor and Description |
---|
OncRpcTcpServerTransport(OncRpcDispatchable dispatcher,
InetAddress bindAddr,
int port,
OncRpcServerTransportRegistrationInfo[] info,
int bufferSize)
Create a new instance of a
OncRpcTcpServerTransport which
encapsulates TCP/IP-based XDR streams of an ONC/RPC server. |
OncRpcTcpServerTransport(OncRpcDispatchable dispatcher,
int port,
int program,
int version,
int bufferSize)
Create a new instance of a
OncRpcTcpServerTransport which
encapsulates TCP/IP-based XDR streams of an ONC/RPC server. |
OncRpcTcpServerTransport(OncRpcDispatchable dispatcher,
int port,
OncRpcServerTransportRegistrationInfo[] info,
int bufferSize)
Create a new instance of a
OncRpcTcpServerTransport which
encapsulates TCP/IP-based XDR streams of an ONC/RPC server. |
Modifier and Type | Method and Description |
---|---|
protected void |
beginEncoding(OncRpcCallInformation callInfo,
OncRpcServerReplyMessage state)
Do not call.
|
void |
close()
Close the server transport and free any resources associated with it.
|
protected void |
endDecoding()
Do not call.
|
protected void |
endEncoding()
Do not call.
|
String |
getCharacterEncoding()
Get the character encoding for (de-)serializing strings.
|
int |
getTransmissionTimeout()
Retrieve the current timeout used during transmission phases (call and
reply phases).
|
protected XdrDecodingStream |
getXdrDecodingStream()
Do not call.
|
protected XdrEncodingStream |
getXdrEncodingStream()
Do not call.
|
void |
listen()
Creates a new thread and uses this thread to listen to incoming
ONC/RPC requests, then dispatches them and finally sends back the
appropriate reply messages.
|
void |
register()
Register the TCP/IP port where this server transport waits for incoming
requests with the ONC/RPC portmapper.
|
protected void |
removeTransport(OncRpcTcpConnectionServerTransport transport)
Removes a TCP/IP server transport from the list of currently open
transports.
|
protected void |
reply(OncRpcCallInformation callInfo,
OncRpcServerReplyMessage state,
XdrAble reply)
Do not call.
|
void |
retrieveCall(XdrAble call)
Do not call.
|
void |
setCharacterEncoding(String characterEncoding)
Set the character encoding for (de-)serializing strings.
|
void |
setTransmissionTimeout(int milliseconds)
Set the timeout used during transmission of data.
|
getPort, unregister
protected int transmissionTimeout
public OncRpcTcpServerTransport(OncRpcDispatchable dispatcher, int port, int program, int version, int bufferSize) throws OncRpcException, IOException
OncRpcTcpServerTransport
which
encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
particular server transport only waits for incoming connection requests
and then creates OncRpcTcpConnectionServerTransport
server transports
to handle individual connections.
This constructor is a convenience constructor for those transports
handling only a single ONC/RPC program and version number.dispatcher
- Reference to interface of an object capable of
dispatching (handling) ONC/RPC calls.port
- Number of port where the server will wait for incoming
calls.program
- Number of ONC/RPC program handled by this server
transport.version
- Version number of ONC/RPC program handled.bufferSize
- Size of buffer used when receiving and sending
chunks of XDR fragments over TCP/IP. The fragments built up to
form ONC/RPC call and reply messages.OncRpcException
- if an RPC error occurs.IOException
- if an IO error occurs.public OncRpcTcpServerTransport(OncRpcDispatchable dispatcher, int port, OncRpcServerTransportRegistrationInfo[] info, int bufferSize) throws OncRpcException, IOException
OncRpcTcpServerTransport
which
encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
particular server transport only waits for incoming connection requests
and then creates OncRpcTcpConnectionServerTransport
server transports
to handle individual connections.dispatcher
- Reference to interface of an object capable of
dispatching (handling) ONC/RPC calls.port
- Number of port where the server will wait for incoming
calls.info
- Array of program and version number tuples of the ONC/RPC
programs and versions handled by this transport.bufferSize
- Size of buffer used when receiving and sending
chunks of XDR fragments over TCP/IP. The fragments built up to
form ONC/RPC call and reply messages.OncRpcException
- if an RPC error occurs.IOException
- if an IO error occurs.public OncRpcTcpServerTransport(OncRpcDispatchable dispatcher, InetAddress bindAddr, int port, OncRpcServerTransportRegistrationInfo[] info, int bufferSize) throws OncRpcException, IOException
OncRpcTcpServerTransport
which
encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
particular server transport only waits for incoming connection requests
and then creates OncRpcTcpConnectionServerTransport
server transports
to handle individual connections.dispatcher
- Reference to interface of an object capable of
dispatching (handling) ONC/RPC calls.bindAddr
- The local Internet Address the server will bind to.port
- Number of port where the server will wait for incoming
calls.info
- Array of program and version number tuples of the ONC/RPC
programs and versions handled by this transport.bufferSize
- Size of buffer used when receiving and sending
chunks of XDR fragments over TCP/IP. The fragments built up to
form ONC/RPC call and reply messages.OncRpcException
- if an RPC error occurs.IOException
- if an IO error occurs.public void close()
Note that the server transport is not deregistered. You'll have to do it manually if you need to do so. The reason for this behaviour is, that the portmapper removes all entries regardless of the protocol (TCP/IP or UDP/IP) for a given ONC/RPC program number and version.
Calling this method on a OncRpcTcpServerTransport
results in the listening TCP network socket immediately being closed.
In addition, all server transports handling the individual TCP/IP
connections will also be closed. The handler threads will therefore
either terminate directly or when they try to sent back replies.
close
in class OncRpcServerTransport
protected void removeTransport(OncRpcTcpConnectionServerTransport transport)
transport
- Server transport to remove from the list of currently
open transports for this listening transport.public void register() throws OncRpcException
register
in class OncRpcServerTransport
OncRpcException
- if the portmapper could not be contacted
successfully of if the portmapper rejected port registration(s).public void retrieveCall(XdrAble call) throws OncRpcException, IOException
retrieveCall
in class OncRpcServerTransport
call
- An XDR able object instance, where to decode the
call information in.Error
- because this method must not be called for a listening
server transport.OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully deserialized.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.protected XdrDecodingStream getXdrDecodingStream()
getXdrDecodingStream
in class OncRpcServerTransport
Error
- because this method must not be called for a listening
server transport.protected void endDecoding() throws OncRpcException, IOException
endDecoding
in class OncRpcServerTransport
Error
- because this method must not be called for a listening
server transport.OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully deserialized.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.protected XdrEncodingStream getXdrEncodingStream()
getXdrEncodingStream
in class OncRpcServerTransport
Error
- because this method must not be called for a listening
server transport.protected void beginEncoding(OncRpcCallInformation callInfo, OncRpcServerReplyMessage state) throws OncRpcException, IOException
beginEncoding
in class OncRpcServerTransport
callInfo
- Information about ONC/RPC call for which we are about
to send back the reply.state
- ONC/RPC reply header indicating success or failure.Error
- because this method must not be called for a listening
server transport.OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully serialized.IOException
- if an I/O exception occurs, like transmissionprotected void endEncoding() throws OncRpcException, IOException
endEncoding
in class OncRpcServerTransport
Error
- because this method must not be called for a listening
server transport.OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully serialized.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.protected void reply(OncRpcCallInformation callInfo, OncRpcServerReplyMessage state, XdrAble reply) throws OncRpcException, IOException
reply
in class OncRpcServerTransport
callInfo
- information about the original call, which are necessary
to send back the reply to the appropriate caller.state
- ONC/RPC reply message header indicating success or failure
and containing associated state information.reply
- If not null
, then this parameter references
the reply to be serialized after the reply message header.Error
- because this method must not be called for a listening
server transport.OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully serialized.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.OncRpcCallInformation
,
OncRpcDispatchable
public void listen()
For every incomming TCP/IP connection a handler thread is created to handle ONC/RPC calls on this particular connection.
listen
in class OncRpcServerTransport
public void setTransmissionTimeout(int milliseconds)
milliseconds
- Transmission timeout in milliseconds.public int getTransmissionTimeout()
public void setCharacterEncoding(String characterEncoding)
setCharacterEncoding
in class OncRpcServerTransport
characterEncoding
- the encoding to use for (de-)serializing strings.
If null
, the system's default encoding is to be used.public String getCharacterEncoding()
getCharacterEncoding
in class OncRpcServerTransport
null
, then the system's default encoding is used.Copyright © 2022. All rights reserved.