sg.edu.nus.peer.request
Class ServerPnPServer

java.lang.Object
  extended by sg.edu.nus.peer.request.UDPServer
      extended by sg.edu.nus.peer.request.ServerPnPServer
All Implemented Interfaces:
java.lang.Runnable

public class ServerPnPServer
extends UDPServer

The ServerPnPServer is used for sending and receiving UDP messages between peers, which is composed of a ServerPnPSender and a ServerPnPReceiver. The ServerPnPSender is responsible for sending MsgType.PING messages to, bootstrapper, server peers in its routing table and its client peers, while the ServerPnPReceiver for receiving MsgType.PONG messages.

To start the ServerPnPServer, just implement the following codes in the run() method.

 public void run()
 {
        sender = new ServerPnPSender();
        scheduler = new Timer("Ping Sender of Server Peer");
        scheduler.schedule(sender, 10000); // 10 seconds
 
        receiver = new ServerPnPReceiver(sender.getSocket(), 10);
        Thread receiverThread = new Thread("Pong Receiver of Server Peer", receiver);
        receiverThread.start();
 }
 

Version:
1.0 2006-9-25
Author:
Xu Linhao
See Also:
UDPServer, ServerPnPSender, ServerPnPReceiver

Constructor Summary
ServerPnPServer(AbstractMainFrame gui, int port, int maxConn, long period)
          Construct the ServerPnPServer with specified paramemters.
 
Method Summary
 void run()
          Start both sender and receiver for processing UDP messages.
 
Methods inherited from class sg.edu.nus.peer.request.UDPServer
getDatagramSocket, getLocalPort, isAlive, scheduleUDPSender, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPnPServer

public ServerPnPServer(AbstractMainFrame gui,
                       int port,
                       int maxConn,
                       long period)
                throws java.net.SocketException
Construct the ServerPnPServer with specified paramemters.

Parameters:
gui - the reference of AbstractMainFrame
port - the port to be used for starting the server
maxConn - the maximum number of handlers used for processing UDP messages
period - the sitting up time used for initiating next round of UDP packets dissemination
Throws:
java.net.SocketException - if open socket on the port fails
Method Detail

run

public void run()
Start both sender and receiver for processing UDP messages.