public class XdrUdpDecodingStream extends XdrDecodingStream
XdrUdpDecodingStream
class provides the necessary
functionality to XdrDecodingStream
to receive XDR packets from the
network using the datagram-oriented UDP/IP.Constructor and Description |
---|
XdrUdpDecodingStream(DatagramSocket datagramSocket,
int bufferSize)
Construct a new
XdrUdpDecodingStream object and associate
it with the given datagramSocket for UDP/IP-based
communication. |
Modifier and Type | Method and Description |
---|---|
void |
beginDecoding()
Initiates decoding of the next XDR record.
|
void |
close()
Closes this decoding XDR stream and releases any system resources
associated with this stream.
|
void |
endDecoding()
End decoding of the current XDR record.
|
InetAddress |
getSenderAddress()
Returns the Internet address of the sender of the current XDR data.
|
int |
getSenderPort()
Returns the port number of the sender of the current XDR data.
|
int |
xdrDecodeInt()
Decodes (aka "deserializes") a "XDR int" value received from a
XDR stream.
|
void |
xdrDecodeOpaque(byte[] opaque,
int offset,
int length)
Decodes (aka "deserializes") a XDR opaque value, which is represented
by a vector of byte values, and starts at
offset with a
length of length . |
byte[] |
xdrDecodeOpaque(int length)
Decodes (aka "deserializes") an opaque value, which is nothing more
than a series of octets (or 8 bits wide bytes).
|
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
public XdrUdpDecodingStream(DatagramSocket datagramSocket, int bufferSize)
XdrUdpDecodingStream
object and associate
it with the given datagramSocket
for UDP/IP-based
communication. This constructor is typically used when communicating
with servers over UDP/IP using a "connected" datagram socket.datagramSocket
- Datagram socket from which XDR data is received.bufferSize
- Size of packet buffer for storing received XDR
datagrams.public InetAddress getSenderAddress()
beginDecoding()
,
otherwise it might return stale information.getSenderAddress
in class XdrDecodingStream
public int getSenderPort()
beginDecoding()
,
otherwise it might return stale information.getSenderPort
in class XdrDecodingStream
public void beginDecoding() throws OncRpcException, IOException
beginDecoding
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public void endDecoding() throws OncRpcException, IOException
endDecoding
is 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 does nothing
more than resetting the buffer pointer (eeek! a pointer in Java!!!) back
to the begin of an empty buffer, so attempts to decode data will fail
until the buffer is filled again.
endDecoding
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public void close() throws OncRpcException, IOException
This implementation frees the allocated buffer but does not close the associated datagram socket. It only throws away the reference to this socket.
close
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public int xdrDecodeInt() throws OncRpcException, IOException
xdrDecodeInt
in class XdrDecodingStream
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public byte[] xdrDecodeOpaque(int length) throws OncRpcException, IOException
xdrDecodeOpaque(byte[], int, int)
where
first the length of the opaque value is retrieved from the XDR stream.xdrDecodeOpaque
in class XdrDecodingStream
length
- Length of opaque data to decode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.public void xdrDecodeOpaque(byte[] opaque, int offset, int length) throws OncRpcException, IOException
offset
with a
length of length
. 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).xdrDecodeOpaque
in class XdrDecodingStream
opaque
- Byte vector which will receive the decoded opaque value.offset
- Start offset in the byte vector.length
- the number of bytes to decode.OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.Copyright © 2022. All rights reserved.