This is the generic datagram interface. It represents an object that will act as the holder of data to be send or received from a datagram connection. The DataInput and DataOutput interfaces are extended by this interface to provide a simple way to read and write binary data in and out of the datagram buffer. A special function reset() may be called to reset the read/write point to the beginning of the buffer.
Method Summary | |
String |
getAddress()
Get the address in the datagram |
byte[] |
getData()
Get the buffer |
int |
getLength()
Get the length |
int |
getOffset()
Get the offset |
void |
reset()
Reset the read/write pointer and zeros the offset and length parameters. |
void |
setAddress(Datagram reference)
Set datagram address, copying the address from another datagram. |
void |
setAddress(String addr)
Set datagram address. |
void |
setData(byte[] buffer,
int offset,
int len)
Set the buffer, offset and length |
void |
setLength(int len)
Set the length |
Methods inherited from interface java.io.DataInput |
readBoolean,
readByte,
readChar,
readFully,
readFully,
readInt,
readLong,
readShort,
readUnsignedByte,
readUnsignedShort,
readUTF,
skipBytes |
Methods inherited from interface java.io.DataOutput |
write,
write,
write,
writeBoolean,
writeByte,
writeChar,
writeChars,
writeInt,
writeLong,
writeShort,
writeUTF |
Method Detail |
public String getAddress()
public byte[] getData()
public int getLength()
public int getOffset()
public void setAddress(String addr) throws IOException
{protocol}:{target}E.g. The "target" can be "//{host}:{port}" (but is not necessarily limited to this.)
datagram://123.456.789.12:1234Note that if the address of a datagram is not specified, then it defaults to that of the connection.
addr
- the new target address as a URLpublic void setAddress(Datagram reference)
reference
- the datagram who's address will be copied as
the new target address for this datagram.public void setLength(int len)
len
- the new length of the datapublic void setData(byte[] buffer, int offset, int len)
addr
- the data bufferoffset
- the offset into the data bufferlen
- the length of the data in the bufferpublic void reset()