aleph.comm.udp
Class Packet
java.lang.Object
|
+--aleph.comm.udp.Packet
- public class Packet
- extends java.lang.Object
- implements java.io.Serializable, Constants
- See Also:
- Serialized Form
|
Constructor Summary |
Packet(int type)
Constructor |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
next
public transient Packet next
Packet
public Packet(int type)
- Constructor
- Parameters:
type - what kind of packet?- See Also:
aleph.comm.datagram.Constants
main
public static void main(java.lang.String[] args)
getType
public int getType()
setType
public void setType(int type)
getSeqnum
public int getSeqnum()
setSeqnum
public void setSeqnum(int seq)
getAcknum
public int getAcknum()
setAcknum
public void setAcknum(int ack)
setAddress
public void setAddress(Address address)
getAddress
public Address getAddress()
available
public int available()
- Returns:
- number of unused data bytes in packet.
empty
public boolean empty()
- Returns:
- any data bytes in packet?
append
public void append(int b)
- Write byte to packet. Beware: panics on overflow!
- Parameters:
b - byte written
append
public void append(byte[] b,
int off,
int len)
- Write bytes to packet. Beware: panics on overflow!
- Parameters:
b - array of bytesoff - starting offsetlen - number of bytes to write
read
public int read()
- Returns next byte from packet, or -1 if nothing left.
read
public int read(byte[] b,
int off,
int len)
- Reads up to
len bytes of data into an array of bytes.
- Parameters:
b - target arrayoff - offset in arraylen - number of bytes- Returns:
- number actually copied
send
public void send(java.net.DatagramSocket socket,
Address destination)
throws java.io.IOException
- Send the packet.
- Parameters:
socket - This PE's socketaddress - Destination address
receive
public static Packet receive(java.net.DatagramSocket socket)
throws java.io.InterruptedIOException
- Receives and returns a packet from the network.
- Parameters:
socket - Datagram socket on which to listen.
readInt
protected int readInt(int index)
writeInt
protected void writeInt(int index,
int v)
read4Bytes
protected void read4Bytes(int index,
byte[] b)
write4Bytes
protected void write4Bytes(int index,
byte[] b)
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object