public class OncRpcTcpConnectionServerTransport extends OncRpcServerTransport
OncRpcTcpServerTransport
encapsulate
TCP/IP-based XDR streams of ONC/RPC servers. This server transport class
is responsible for receiving ONC/RPC calls over TCP/IP.OncRpcServerTransport
,
OncRpcTcpServerTransport
,
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 |
---|
OncRpcTcpConnectionServerTransport(OncRpcDispatchable dispatcher,
Socket socket,
int program,
int version,
int bufferSize,
OncRpcTcpServerTransport parent,
int transmissionTimeout)
Create a new instance of a
OncRpcTcpSConnectionerverTransport
which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. |
OncRpcTcpConnectionServerTransport(OncRpcDispatchable dispatcher,
Socket socket,
OncRpcServerTransportRegistrationInfo[] info,
int bufferSize,
OncRpcTcpServerTransport parent,
int transmissionTimeout)
Create a new instance of a
OncRpcTcpSConnectionerverTransport
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)
Begins the sending phase for ONC/RPC replies.
|
void |
close()
Close the server transport and free any resources associated with it.
|
protected void |
endDecoding()
Finishes call parameter deserialization.
|
protected void |
endEncoding()
Finishes encoding the reply to this ONC/RPC call.
|
protected void |
finalize()
Finalize object by making sure that we're removed from the list
of open transports which our parent transport maintains.
|
String |
getCharacterEncoding()
Get the character encoding for (de-)serializing strings.
|
protected XdrDecodingStream |
getXdrDecodingStream()
Returns XDR stream which can be used for deserializing the parameters
of this ONC/RPC call.
|
protected XdrEncodingStream |
getXdrEncodingStream()
Returns XDR stream which can be used for eserializing the reply
to this ONC/RPC call.
|
void |
listen()
Creates a new thread and uses this thread to handle the new connection
to receive ONC/RPC requests, then dispatching them and finally sending
back reply messages.
|
void |
register()
Do not call.
|
protected void |
reply(OncRpcCallInformation callInfo,
OncRpcServerReplyMessage state,
XdrAble reply)
Send back an ONC/RPC reply to the original caller.
|
void |
retrieveCall(XdrAble call)
Retrieves the parameters sent within an ONC/RPC call message.
|
void |
setCharacterEncoding(String characterEncoding)
Set the character encoding for (de-)serializing strings.
|
getPort, unregister
protected int transmissionTimeout
public OncRpcTcpConnectionServerTransport(OncRpcDispatchable dispatcher, Socket socket, int program, int version, int bufferSize, OncRpcTcpServerTransport parent, int transmissionTimeout) throws OncRpcException, IOException
OncRpcTcpSConnectionerverTransport
which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
particular server transport handles individual ONC/RPC connections over
TCP/IP. 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.socket
- TCP/IP-based socket of new connection.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.parent
- Parent server transport which created us.transmissionTimeout
- Inherited transmission timeout.OncRpcException
- if an RPC error occurs.IOException
- if an IO error occurs.public OncRpcTcpConnectionServerTransport(OncRpcDispatchable dispatcher, Socket socket, OncRpcServerTransportRegistrationInfo[] info, int bufferSize, OncRpcTcpServerTransport parent, int transmissionTimeout) throws OncRpcException, IOException
OncRpcTcpSConnectionerverTransport
which encapsulates TCP/IP-based XDR streams of an ONC/RPC server. This
particular server transport handles individual ONC/RPC connections over
TCP/IP.dispatcher
- Reference to interface of an object capable of
dispatching (handling) ONC/RPC calls.socket
- TCP/IP-based socket of new connection.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.parent
- Parent server transport which created us.transmissionTimeout
- Inherited transmission timeout.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.
The handler thread will therefore either terminate directly or when
it tries to sent back replies.
close
in class OncRpcServerTransport
protected void finalize()
public void register() throws OncRpcException
register
in class OncRpcServerTransport
Error
- because this method must not be called for an
individual TCP/IP-based server transport.OncRpcException
- if the portmapper could not be contacted
successfully.public void retrieveCall(XdrAble call) throws OncRpcException, IOException
XdrDecodingStream.endDecoding()
to free any
pending resources from the decoding stage.retrieveCall
in class OncRpcServerTransport
call
- An XDR able object instance, where to decode the
call information in.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
protected void endDecoding() throws OncRpcException, IOException
getXdrDecodingStream()
must not be used any more.
This method belongs to the lower-level access pattern when handling
ONC/RPC calls.endDecoding
in class OncRpcServerTransport
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
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.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
getXdrEncodingStream()
any
longer.endEncoding
in class OncRpcServerTransport
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
OncRpcCallInformation.reply(XdrAble)
method instead on the
call object supplied to the handler.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.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()
Currently only one call after the other is dispatched, so no multithreading is done when receiving multiple calls. Instead, later calls have to wait for the current call to finish before they are handled.
listen
in class OncRpcServerTransport
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.