|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xsocket.datagram.UserDatagram
public final class UserDatagram
a datagram packet
| Constructor Summary | |
|---|---|
UserDatagram(byte[] data)
constructor. creates packet sets the content with the given byte array |
|
UserDatagram(java.nio.ByteBuffer data)
constructor. creates packet, and sets the content with the given buffer |
|
UserDatagram(java.net.InetAddress remoteAddress,
int remotePort,
int size)
constructor. creates an empty packet by setting the target remote address |
|
UserDatagram(int size)
constructor. creates an empty packet |
|
UserDatagram(java.net.SocketAddress remoteSocketAddress,
byte[] data)
constructor. creates packet by setting the target remote address, and sets the content with the given byte array |
|
UserDatagram(java.net.SocketAddress remoteSocketAddress,
java.nio.ByteBuffer data)
constructor. creates packet by setting the target remote address, and sets the content with the given buffer |
|
UserDatagram(java.net.SocketAddress address,
int size)
constructor. creates an empty packet by setting the target remote address |
|
UserDatagram(java.lang.String remoteHost,
int remotePort,
byte[] data)
constructor. creates packet by setting the target remote address, and sets the content with the given byte array |
|
UserDatagram(java.lang.String remoteHost,
int remotePort,
int size)
constructor. creates an empty packet by setting the target remote address |
|
| Method Summary | |
|---|---|
int |
getRemaining()
get the remaining, unwritten packet size |
java.net.InetAddress |
getRemoteAddress()
Returns the address of the machine to which this packet is being sent or from which the packet was received. |
int |
getRemotePort()
Returns the port number of the machine to which this packet is being sent or from which the packet was received. |
java.net.SocketAddress |
getRemoteSocketAddress()
Returns the socket address of the machine to which this packet is being sent or from which the packet was received. |
int |
getSize()
get the packet size |
byte |
readByte()
read a byte |
java.nio.ByteBuffer |
readByteBuffer()
read all remaining data as ByteBuffer |
java.nio.ByteBuffer |
readByteBufferByDelimiter(java.lang.String delimiter,
int maxLength)
read a ByteBuffer by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
java.nio.ByteBuffer |
readByteBufferByLength(int length)
read a ByteBuffer by using a length defintion |
byte[] |
readBytes()
reads the remaining data as byte array |
byte[] |
readBytesByDelimiter(java.lang.String delimiter,
int maxLength)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByLength(int length)
read bytes by using a length defintion |
double |
readDouble()
read a double |
int |
readInt()
read an int |
long |
readLong()
read a long |
short |
readShort()
read an short |
java.lang.String |
readString()
read the remaining data as String |
java.lang.String |
readString(java.lang.String encoding)
read the remaining data as String |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter)
read a string by using a delimiter and the connection default encoding |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
int maxLength)
read a string by using a delimiter and the connection default encoding |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
int maxLength)
read a string by using a delimiter |
java.lang.String |
readStringByLength(int length)
read a string by using a length definition and the connection default encoding |
java.lang.String |
readStringByLength(int length,
java.lang.String encoding)
read a string by using a length definition |
java.lang.String |
toString()
|
int |
write(byte... bytes)
writes bytes to the packet |
int |
write(byte b)
writes a byte to the packet |
int |
write(byte[] bytes,
int offset,
int length)
writes bytes to the packet |
int |
write(java.nio.ByteBuffer buffer)
writes a byte buffer to the packet |
long |
write(java.nio.ByteBuffer[] buffers)
writes a byte array to the packet |
int |
write(double d)
writes a double to the packet |
int |
write(int i)
writes a int to the packet |
int |
write(long l)
writes a long to the packet |
int |
write(short s)
writes a short to the packet |
int |
write(java.lang.String message)
write a message |
int |
write(java.lang.String message,
java.lang.String encoding)
write a message |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UserDatagram(int size)
size - the packet size
public UserDatagram(java.lang.String remoteHost,
int remotePort,
int size)
remoteHost - the destination hostnameremotePort - the destination port numbersize - the packet size
public UserDatagram(java.net.InetAddress remoteAddress,
int remotePort,
int size)
remoteAddress - the destination addressremotePort - the destination port numbersize - the packet size
public UserDatagram(java.net.SocketAddress address,
int size)
address - the destination addresssize - the packet sizepublic UserDatagram(java.nio.ByteBuffer data)
data - the data which will be written into the buffer
public UserDatagram(java.net.SocketAddress remoteSocketAddress,
java.nio.ByteBuffer data)
remoteSocketAddress - the destination addressdata - the data which will be written into the bufferpublic UserDatagram(byte[] data)
data - the data which will be written into the buffer
public UserDatagram(java.lang.String remoteHost,
int remotePort,
byte[] data)
remoteHost - the destination hostnameremotePort - the destination port numberdata - the data which will be written into the buffer
public UserDatagram(java.net.SocketAddress remoteSocketAddress,
byte[] data)
remoteSocketAddress - the destination addressdata - the data which will be written into the buffer| Method Detail |
|---|
public java.net.SocketAddress getRemoteSocketAddress()
public java.net.InetAddress getRemoteAddress()
public int getRemotePort()
public byte readByte()
throws java.io.IOException,
java.nio.BufferUnderflowException
readByte in interface IDataSourcejava.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public java.nio.ByteBuffer readByteBufferByLength(int length)
throws java.io.IOException,
java.nio.BufferUnderflowException
length - the amount of bytes to read
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public byte[] readBytesByLength(int length)
throws java.io.IOException,
java.nio.BufferUnderflowException
readBytesByLength in interface IDataSourcelength - the amount of bytes to read
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public java.lang.String readStringByLength(int length,
java.lang.String encoding)
throws java.io.IOException,
java.nio.BufferUnderflowException,
java.io.UnsupportedEncodingException
readStringByLength in interface IDataSourcelength - the amount of bytes to readencoding - the encoding to use
java.io.IOException - If some other I/O error occurs
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.UnsupportedEncodingException - if the given encoding is not supported
public java.lang.String readStringByLength(int length)
throws java.io.IOException,
java.nio.BufferUnderflowException,
java.io.UnsupportedEncodingException
readStringByLength in interface IDataSourcelength - the amount of bytes to read
java.io.IOException - If some other I/O error occurs
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.UnsupportedEncodingException - if the given encoding is not supported
public double readDouble()
throws java.io.IOException,
java.nio.BufferUnderflowException
readDouble in interface IDataSourcejava.io.IOException - If some other I/O error occurs
java.nio.BufferUnderflowException
public int readInt()
throws java.io.IOException,
java.nio.BufferUnderflowException
readInt in interface IDataSourcejava.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public short readShort()
throws java.io.IOException,
java.nio.BufferUnderflowException
readShort in interface IDataSourcejava.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public long readLong()
throws java.io.IOException,
java.nio.BufferUnderflowException
readLong in interface IDataSourcejava.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public java.nio.ByteBuffer readByteBuffer()
throws java.io.IOException
java.io.IOException - If some other I/O error occurs
public byte[] readBytes()
throws java.io.IOException
java.io.IOException - If some other I/O error occurs
public java.lang.String readString()
throws java.io.IOException,
java.io.UnsupportedEncodingException
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - if the default encoding is not supported
public java.lang.String readString(java.lang.String encoding)
throws java.io.IOException,
java.io.UnsupportedEncodingException
encoding - the encoding to use
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - if the default encoding is not supported
public java.lang.String readStringByDelimiter(java.lang.String delimiter)
throws java.io.IOException,
java.nio.BufferUnderflowException,
java.io.UnsupportedEncodingException
readStringByDelimiter in interface IDataSourcedelimiter - the delimiter
java.io.IOException - If some other I/O error occurs
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.UnsupportedEncodingException - if the default encoding is not supported
public java.lang.String readStringByDelimiter(java.lang.String delimiter,
int maxLength)
throws java.io.IOException,
java.nio.BufferUnderflowException,
java.io.UnsupportedEncodingException,
MaxReadSizeExceededException
readStringByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit will be exceeded a MaxReadSizeExceededException will been thrown
java.io.IOException - If some other I/O error occurs
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
java.io.UnsupportedEncodingException - if the default encoding is not supported
public java.lang.String readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
int maxLength)
throws java.io.IOException,
java.nio.BufferUnderflowException,
java.io.UnsupportedEncodingException,
MaxReadSizeExceededException
readStringByDelimiter in interface IDataSourcedelimiter - the delimiterencoding - the encodin to usemaxLength - the max length of bytes that should be read. If the limit will be exceeded a MaxReadSizeExceededException will been thrown
java.io.IOException - If some other I/O error occurs
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.io.UnsupportedEncodingException - if the given encoding is not supported
public java.nio.ByteBuffer readByteBufferByDelimiter(java.lang.String delimiter,
int maxLength)
throws java.io.IOException,
java.nio.BufferUnderflowException,
MaxReadSizeExceededException
delimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.io.IOException - If some other I/O error occurs
public byte[] readBytesByDelimiter(java.lang.String delimiter,
int maxLength)
throws java.io.IOException,
java.nio.BufferUnderflowException,
MaxReadSizeExceededException
readBytesByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
java.nio.BufferUnderflowException - if the buffer`s limit has been reached
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.io.IOException - If some other I/O error occurs
public int write(byte b)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkb - the byte to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(short s)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinks - the short to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(byte... bytes)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkbytes - the bytes to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(byte[] bytes,
int offset,
int length)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkbytes - the bytes to writeoffset - The offset of the subarray to be used; must be non-negative and no larger than array.length. The new buffer`s position will be set to this value.length - The length of the subarray to be used; must be non-negative and no larger than array.length - offset. The new buffer`s limit will be set to offset + length.
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(java.nio.ByteBuffer buffer)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkbuffer - the bytes to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public long write(java.nio.ByteBuffer[] buffers)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkbuffers - the bytes to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(double d)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkd - the int value to write
java.nio.BufferOverflowException - if the buffer`'s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(int i)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinki - the int value to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(long l)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkl - the int value to write
java.nio.BufferOverflowException - if the buffer`s limit has been reached
java.io.IOException - If some other I/O error occurs
public int write(java.lang.String message)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkmessage - the message to write
java.io.IOException - If some other I/O error occurs
java.nio.BufferOverflowException - if the buffer`s limit has been reached
public int write(java.lang.String message,
java.lang.String encoding)
throws java.io.IOException,
java.nio.BufferOverflowException
write in interface IDataSinkmessage - the message to writeencoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`)
java.io.IOException - If some other I/O error occurs
java.nio.BufferOverflowException - if the buffer`s limit has been reachedpublic int getSize()
public int getRemaining()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||