sg.edu.nus.peer.request
Class BootstrapPnPServer

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

public class BootstrapPnPServer
extends UDPServer

The BootstrapPnPServer is used for sending and receiving UDP messages between peers, which is composed of a BootstrapPnPSender and a BootstrapPnPReceiver. The BootstrapPnPSender is responsible for sending MsgType.PING messages to remote peers, while the BootstrapPnPReceiver for receiving MsgType.PONG messages from remote peers.

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

 public void run()
 {
        sender = new BootstrapPnPSender();
        scheduler = new Timer("Ping Sender of Bootstrap");
        scheduler.schedule(sender, 10000); // for 10 seconds
 
        receiver = new BootstrapPnPReceiver(sender.getSocket(), 10);
        Thread receiverThread = new Thread("Pong Receiver of Bootstrap", receiver);
        receiverThread.start();
 }
 

Version:
1.0 2006-9-25
Author:
Xu Linhao
See Also:
UDPServer, BootstrapPnPSender, BootstrapPnPReceiver

Constructor Summary
BootstrapPnPServer(AbstractMainFrame gui, int port, int maxConn, long period)
          Construct the BootstrapPnPServer 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

BootstrapPnPServer

public BootstrapPnPServer(AbstractMainFrame gui,
                          int port,
                          int maxConn,
                          long period)
                   throws java.net.SocketException
Construct the BootstrapPnPServer 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.