edu.UCL.xmiddle.controller
Class UDPNetwork

java.lang.Object
  |
  +--edu.UCL.xmiddle.framework.controller.Network
        |
        +--edu.UCL.xmiddle.controller.UDPNetwork
All Implemented Interfaces:
java.lang.Runnable

public class UDPNetwork
extends Network
implements java.lang.Runnable


Field Summary
static java.lang.String IP
           
static int MAX_SEGMENT
           
static int PORT
           
 int PRIVATE_PORT
           
 
Fields inherited from class edu.UCL.xmiddle.framework.controller.Network
activeSessions, caller, CONNECTED, DISCONNECTED, localhost, locator, status
 
Constructor Summary
UDPNetwork(LocalHost localhost, Manager manager)
          Creates a new UDPNetwork instance.
 
Method Summary
 boolean connect()
          Connects to the network
 Listener createListener(Host host, java.lang.Object sessionID)
          Returns a listener to the given host for the given protocol session.
 Sender createSender(Host host, java.lang.Object sessionID)
          Not implemented (see createListener)
 void disconnect()
          Immediatly disconnects from the network, killing all protocols and acknowledgers that are running
 void exit()
          Signifies that we are about to exit
 java.net.MulticastSocket getConnection()
          Returns the multicast socket used to communicate with the xmiddle group
 void registerSession(ProtocolChooser session)
          Registers a new protocol session
 void removeSession(java.lang.Object sessionID)
          Removes a protocol session
 void run()
          receives messages sent and queues them to be processed by the message queue processor
 boolean send(Data data)
          Sends data to a remote host
 
Methods inherited from class edu.UCL.xmiddle.framework.controller.Network
getStatus, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIVATE_PORT

public int PRIVATE_PORT

PORT

public static final int PORT
See Also:
Constant Field Values

IP

public static final java.lang.String IP
See Also:
Constant Field Values

MAX_SEGMENT

public static int MAX_SEGMENT
Constructor Detail

UDPNetwork

public UDPNetwork(LocalHost localhost,
                  Manager manager)
Creates a new UDPNetwork instance.

Parameters:
localhost - a reference to the localhost so that we can queue requests
manager - not used currently (can be null)
Method Detail

run

public void run()
receives messages sent and queues them to be processed by the message queue processor

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class Network

getConnection

public java.net.MulticastSocket getConnection()
Returns the multicast socket used to communicate with the xmiddle group

Returns:
a MulticastSocket value

connect

public boolean connect()
Connects to the network

Specified by:
connect in class Network
Returns:
TRUE if the operation succeeded or false otherwise

disconnect

public void disconnect()
Immediatly disconnects from the network, killing all protocols and acknowledgers that are running

Specified by:
disconnect in class Network

exit

public void exit()
Signifies that we are about to exit

Specified by:
exit in class Network

send

public boolean send(Data data)
Sends data to a remote host

Specified by:
send in class Network
Parameters:
data - a Data value
Returns:
a boolean value

createSender

public Sender createSender(Host host,
                           java.lang.Object sessionID)
Not implemented (see createListener)

Specified by:
createSender in class Network
Parameters:
host - a Host value
sessionID - an Object value
Returns:
a Sender value

createListener

public Listener createListener(Host host,
                               java.lang.Object sessionID)
Returns a listener to the given host for the given protocol session. Note that the same DatagramSocket will be used for the Sender (assigned by the MessageQueueProcessor), which will assign the Sender automatically.

Specified by:
createListener in class Network
Parameters:
host - the remote host
sessionID - The id of the session for which this listener is being created
Returns:
a Listener value

removeSession

public void removeSession(java.lang.Object sessionID)
                   throws InvalidSessionIDException
Removes a protocol session

Specified by:
removeSession in class Network
Parameters:
sessionID - The session ID
Throws:
InvalidSessionIDException - if the session was not registered

registerSession

public void registerSession(ProtocolChooser session)
                     throws ExistingSessionIDException
Registers a new protocol session

Specified by:
registerSession in class Network
Parameters:
session - a ProtocolChooser value
Throws:
ExistingSessionIDException - if a session with the same ID has been registered