mcast
Class TOMCastPacket

java.lang.Object
  extended by mcast.MCastPacket
      extended by mcast.TOMCastPacket

public class TOMCastPacket
extends MCastPacket

An TOMMCastPacket is a:

   |-------------------------------------------------------------------|
   |    clock     |                user payload                        |
   |   (header)   |                                                    |
   |-------------------------------------------------------------------|
 
The clock is 4 bytes. A TOMCastPacket expects to be the payload of an MCastPacket. In fact, it contains an MCastPacket that it uses to send/receive itself.

Version:
$Id: TOMCastPacket.java,v 1.1.1.1 2009/01/13 03:43:28 zahorjan Exp $

Field Summary
private static int HEADER_SIZE
           
 
Fields inherited from class mcast.MCastPacket
buf, CLIENT_CLIENT_GOODBYE, CLIENT_MCAST, CLIENT_SERVER_HELLO, MAX_PACKET_SIZE, MAX_PAYLOAD_SIZE, SERVER_CLIENT_HELLO, SOCKET_CLOSED
 
Constructor Summary
TOMCastPacket()
          Constructor for outgoing packets: creates packet with TOMCast header, but no payload.
TOMCastPacket(MCastPacket pkt)
          Constructor for incoming packets: takes an MCastPacket received off the network and views it as a TOMCastPacket.
 
Method Summary
 int getClock()
           
 byte[] getPayload()
          Returns the payload - everything past the MCastPacket header.
 int getPayloadLength()
          Returns the number of bytes in the packet past the MCastPacket header.
 void setClock(int clock)
          Sets the TOMCastPacket header clock field.
 void setPayload(byte[] payload)
          Sets the payload: the packet bytes past the TOMCastPacket header.
protected  void setPayloadLength(int len)
          Direct manipulation of the payload length.
 java.lang.String toString()
          The obligatory toString.
 
Methods inherited from class mcast.MCastPacket
getAddress, getBuf, getDGPacket, getType, setAddress, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEADER_SIZE

private static final int HEADER_SIZE
See Also:
Constant Field Values
Constructor Detail

TOMCastPacket

public TOMCastPacket()
Constructor for outgoing packets: creates packet with TOMCast header, but no payload.


TOMCastPacket

public TOMCastPacket(MCastPacket pkt)
Constructor for incoming packets: takes an MCastPacket received off the network and views it as a TOMCastPacket.

Method Detail

setClock

public void setClock(int clock)
Sets the TOMCastPacket header clock field.

Parameters:
clock - The value to be put in the header.

getClock

public int getClock()
Returns:
The clock field in the TOMCastPacket header.

setPayload

public void setPayload(byte[] payload)
Sets the payload: the packet bytes past the TOMCastPacket header. Sets the payload length as a side effect.

Overrides:
setPayload in class MCastPacket
Parameters:
payload - The data to be put in the payload field.

setPayloadLength

protected void setPayloadLength(int len)
Direct manipulation of the payload length.

Overrides:
setPayloadLength in class MCastPacket
Parameters:
len - payload length (excludes header)

getPayload

public byte[] getPayload()
Description copied from class: MCastPacket
Returns the payload - everything past the MCastPacket header.

Overrides:
getPayload in class MCastPacket
Returns:
The TOMCastPacket payload (everything past the TOMCastPacket header).

getPayloadLength

public int getPayloadLength()
Description copied from class: MCastPacket
Returns the number of bytes in the packet past the MCastPacket header.

Overrides:
getPayloadLength in class MCastPacket
Returns:
The number of data bytes in the packet (past the TOMCastPacket header).

toString

public java.lang.String toString()
The obligatory toString.

Overrides:
toString in class MCastPacket