roomba.roombanetwork.util
Class SocketServer

java.lang.Object
  extended by roomba.roombanetwork.util.SocketServer
All Implemented Interfaces:
java.lang.Runnable

public class SocketServer
extends java.lang.Object
implements java.lang.Runnable

This class accepts connections from socket clients and processes incoming messages

Author:
Drew Housten

Constructor Summary
SocketServer(int port, SocketListener listener)
          Constructor to set up the server.
SocketServer(int port, SocketListener listener, boolean verbose)
          Constructor to set up the server.
SocketServer(SocketListener listener)
          Constructor to set up the server.
SocketServer(SocketListener listener, boolean verbose)
          Constructor to set up the server.
 
Method Summary
 void disconnect()
          Called when the server should be shutdown and all clients disconnected
 int getPort()
          Returns the port that the server is running on
 boolean isConnected()
          Indicates if the server is connected to a client
static void main(java.lang.String[] args)
          Test main method
 void run()
          Run method used to accept new connections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketServer

public SocketServer(int port,
                    SocketListener listener)
Constructor to set up the server.

Parameters:
port - The port to listen on
listener - The listener that should be notified whenever there is a new message

SocketServer

public SocketServer(int port,
                    SocketListener listener,
                    boolean verbose)
Constructor to set up the server.

Parameters:
port - The port to listen on
listener - The listener that should be notified whenever there is a new message
verbose - True iff the server output should be verbose

SocketServer

public SocketServer(SocketListener listener)
Constructor to set up the server.

Parameters:
listener - The listener that should be notified whenever there is a new message

SocketServer

public SocketServer(SocketListener listener,
                    boolean verbose)
Constructor to set up the server.

Parameters:
listener - The listener that should be notified whenever there is a new message
verbose - True iff the server output should be verbose
Method Detail

getPort

public int getPort()
Returns the port that the server is running on

Returns:
The port that the server is running on

disconnect

public void disconnect()
Called when the server should be shutdown and all clients disconnected


isConnected

public boolean isConnected()
Indicates if the server is connected to a client

Returns:
true iff the server is connected to a client

run

public void run()
Run method used to accept new connections

Specified by:
run in interface java.lang.Runnable

main

public static final void main(java.lang.String[] args)
Test main method