Class ServerPnPServer

  extended by
      extended by
All Implemented Interfaces:

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);

1.0 2006-9-25
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
getDatagramSocket, getLocalPort, isAlive, scheduleUDPSender, stop
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


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

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: - if open socket on the port fails
Method Detail


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