edu.UCL.xmiddle.controller
Class UDPListener

java.lang.Object
  |
  +--edu.UCL.xmiddle.controller.UDPListener
All Implemented Interfaces:
Listener

public class UDPListener
extends java.lang.Object
implements Listener

UDPListener receives data from a specific host, which is given upon creation of the instance

Since:
1.0
See Also:
Listener

Constructor Summary
UDPListener(java.net.DatagramSocket socket, UDPHost host)
          Creates a new UDPListener instance.
 
Method Summary
 void close()
          Closes the datagram socket.
 int getSegment()
          Returns the maximum size of the data packet we expect
 Data rawReceive()
          receives a packet without negotitating packet size
 Data receive()
          Receives a Data packet from the remote host.
 void setSegment(int segment)
          Sets the maximum size of the data packet we expect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPListener

public UDPListener(java.net.DatagramSocket socket,
                   UDPHost host)
Creates a new UDPListener instance.

Parameters:
socket - The datagram socket from which the data are going to be received
host - The host from which we expect data
Method Detail

close

public void close()
Closes the datagram socket.

Specified by:
close in interface Listener

getSegment

public int getSegment()
Returns the maximum size of the data packet we expect

Specified by:
getSegment in interface Listener
Returns:
the segment size

setSegment

public void setSegment(int segment)
Sets the maximum size of the data packet we expect

Specified by:
setSegment in interface Listener
Parameters:
segment -

receive

public Data receive()
Receives a Data packet from the remote host. We expect that the packet will have a maximum size as given by setSegment()

Specified by:
receive in interface Listener
Returns:
a Data value

rawReceive

public Data rawReceive()
Description copied from interface: Listener
receives a packet without negotitating packet size

Specified by:
rawReceive in interface Listener
Returns:
the packet received