uk.ac.ic.doc.automed.p2p.communication
Class UDPServer

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.communication.UDPServer
All Implemented Interfaces:
uk.ac.ic.doc.automed.util.thread.Threadable

public class UDPServer
extends java.lang.Object
implements uk.ac.ic.doc.automed.util.thread.Threadable


Constructor Summary
UDPServer(int serverPort, RequestListener handler)
          Creates a new instance of UDPServer
 
Method Summary
static java.net.InetAddress getIPAddress(java.lang.String hostName)
          A static utility method to perform reverse name lookup
 void handleAction()
          Handle actions
 void runAction()
          Implements the runnable action
static void sendUDPRequest(java.net.InetAddress host, int port, byte[] data)
          A static method for sending a UDP request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPServer

public UDPServer(int serverPort,
                 RequestListener handler)
Creates a new instance of UDPServer

Method Detail

runAction

public void runAction()
               throws AutoMedException
Implements the runnable action

Specified by:
runAction in interface uk.ac.ic.doc.automed.util.thread.Threadable
Throws:
AutoMedException

handleAction

public void handleAction()
Handle actions

Specified by:
handleAction in interface uk.ac.ic.doc.automed.util.thread.Threadable

sendUDPRequest

public static void sendUDPRequest(java.net.InetAddress host,
                                  int port,
                                  byte[] data)
                           throws CommunicationException
A static method for sending a UDP request

Parameters:
host - an InetAddress object represent the IP address of target host
port - an int value represent target port
data - a byte array to send
Throws:
CommunicationException

getIPAddress

public static java.net.InetAddress getIPAddress(java.lang.String hostName)
                                         throws CommunicationException
A static utility method to perform reverse name lookup

Throws:
CommunicationException