Package org.acplt.oncrpc
Class XdrTcpDecodingStream
java.lang.Object
org.acplt.oncrpc.XdrDecodingStream
org.acplt.oncrpc.XdrTcpDecodingStream
The
XdrTcpDecodingStream class provides the necessary
functionality to XdrDecodingStream to receive XDR records from the
network using the stream-oriented TCP/IP.- Version:
- $Revision: 1.2 $ $Date: 2005/11/11 21:07:27 $ $State: Exp $ $Locker: $
- Author:
- Harald Albrecht
-
Constructor Summary
ConstructorsConstructorDescriptionXdrTcpDecodingStream(Socket streamingSocket, int bufferSize) Construct a newXdrTcpDecodingStreamobject and associate it with the givenstreamingSocketfor TCP/IP-based communication. -
Method Summary
Modifier and TypeMethodDescriptionvoidInitiates decoding of the next XDR record.voidclose()Closes this decoding XDR stream and releases any system resources associated with this stream.voidEnd decoding of the current XDR record.Returns the Internet address of the sender of the current XDR data.intReturns the port number of the sender of the current XDR data.intDecodes (aka "deserializes") a "XDR int" value received from a XDR stream.voidxdrDecodeOpaque(byte[] opaque, int offset, int length) Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values, and starts atoffsetwith a length oflength.byte[]xdrDecodeOpaque(int length) Decodes (aka "deserializes") an opaque value, which is nothing more than a series of octets (or 8 bits wide bytes).Methods inherited from class org.acplt.oncrpc.XdrDecodingStream
getCharacterEncoding, setCharacterEncoding, xdrDecodeBoolean, xdrDecodeBooleanFixedVector, xdrDecodeBooleanVector, xdrDecodeByte, xdrDecodeByteFixedVector, xdrDecodeByteVector, xdrDecodeDouble, xdrDecodeDoubleFixedVector, xdrDecodeDoubleVector, xdrDecodeDynamicOpaque, xdrDecodeFloat, xdrDecodeFloatFixedVector, xdrDecodeFloatVector, xdrDecodeIntFixedVector, xdrDecodeIntVector, xdrDecodeLong, xdrDecodeLongFixedVector, xdrDecodeLongVector, xdrDecodeOpaque, xdrDecodeShort, xdrDecodeShortFixedVector, xdrDecodeShortVector, xdrDecodeString, xdrDecodeStringFixedVector, xdrDecodeStringVector
-
Constructor Details
-
XdrTcpDecodingStream
Construct a newXdrTcpDecodingStreamobject and associate it with the givenstreamingSocketfor TCP/IP-based communication.- Parameters:
streamingSocket- Socket from which XDR data is received.bufferSize- Size of packet buffer for storing received XDR data.- Throws:
IOException- if the passed socket instance fails to provide an input stream.
-
-
Method Details
-
getSenderAddress
Returns the Internet address of the sender of the current XDR data. This method should only be called afterbeginDecoding(), otherwise it might return stale information.- Specified by:
getSenderAddressin classXdrDecodingStream- Returns:
- InetAddress of the sender of the current XDR data.
-
getSenderPort
public int getSenderPort()Returns the port number of the sender of the current XDR data. This method should only be called afterbeginDecoding(), otherwise it might return stale information.- Specified by:
getSenderPortin classXdrDecodingStream- Returns:
- Port number of the sender of the current XDR data.
-
beginDecoding
Initiates decoding of the next XDR record. For TCP-based XDR decoding streams this reads in the next chunk of data from the network socket (a chunk of data is not necessary the same as a fragment, just enough to fill the internal buffer or receive the remaining part of a fragment).Read in the next bunch of bytes. This can be either a complete fragment, or if the fragments sent by the communication partner are too large for our buffer, only parts of fragments. In every case, this method ensures that there will be more data available in the buffer (or else an exception thrown).
- Specified by:
beginDecodingin classXdrDecodingStream- Throws:
OncRpcException- if an ONC/RPC error occurs.IOException- if an I/O error occurs.
-
endDecoding
End decoding of the current XDR record. The general contract ofendDecodingis that calling it is an indication that the current record is no more interesting to the caller and any allocated data for this record can be freed.This method overrides
XdrDecodingStream.endDecoding(). It reads in and throws away fragments until it reaches the last fragment.- Overrides:
endDecodingin classXdrDecodingStream- Throws:
OncRpcException- if an ONC/RPC error occurs.IOException- if an I/O error occurs.
-
close
Closes this decoding XDR stream and releases any system resources associated with this stream. A closed XDR stream cannot perform decoding operations and cannot be reopened.This implementation frees the allocated buffer but does not close the associated datagram socket. It only throws away the reference to this socket.
- Overrides:
closein classXdrDecodingStream- Throws:
OncRpcException- if an ONC/RPC error occurs.IOException- if an I/O error occurs.
-
xdrDecodeInt
Decodes (aka "deserializes") a "XDR int" value received from a XDR stream. A XDR int is 32 bits wide -- the same width Java's "int" data type has.- Specified by:
xdrDecodeIntin classXdrDecodingStream- Returns:
- The decoded int value.
- Throws:
OncRpcException- if an ONC/RPC error occurs.IOException- if an I/O error occurs.
-
xdrDecodeOpaque
Decodes (aka "deserializes") an opaque value, which is nothing more than a series of octets (or 8 bits wide bytes). Because the length of the opaque value is given, we don't need to retrieve it from the XDR stream. This is different fromxdrDecodeOpaque(byte[], int, int)where first the length of the opaque value is retrieved from the XDR stream.- Specified by:
xdrDecodeOpaquein classXdrDecodingStream- Parameters:
length- Length of opaque data to decode.- Returns:
- Opaque data as a byte vector.
- Throws:
OncRpcException- if an ONC/RPC error occurs.IOException- if an I/O error occurs.
-
xdrDecodeOpaque
public void xdrDecodeOpaque(byte[] opaque, int offset, int length) throws OncRpcException, IOException Decodes (aka "deserializes") a XDR opaque value, which is represented by a vector of byte values, and starts atoffsetwith a length oflength. Only the opaque value is decoded, so the caller has to know how long the opaque value will be. The decoded data is always padded to be a multiple of four (because that's what the sender does).- Specified by:
xdrDecodeOpaquein classXdrDecodingStream- Parameters:
opaque- Byte vector which will receive the decoded opaque value.offset- Start offset in the byte vector.length- the number of bytes to decode.- Throws:
OncRpcException- if an ONC/RPC error occurs.IOException- if an I/O error occurs.
-