All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class connection.socket.Server

java.lang.Object
   |
   +----connection.socket.Server

public abstract class Server
extends Object
Server waits for connection requests from clients. When such a request arrives the server starts a new thread (ServerThread) to communicate with the new client.

Version:
0.30, 1998/04/01
Author:
FRED development team, Antti Viljamaa
See Also:
ServerThread, Client

Variable Index

 o DEFAULT_PORT
The default port of the server.
 o listenSocket
The server socket.
 o portNumber
The port number of the server.

Constructor Index

 o Server(String[])
Creates a server socket to listen for connection requests.

Method Index

 o createMessageHandlers(ConnectionManager, MessageHandler)
Creates the message handlers for the server.
 o fail(Exception, String)
Exit with an error message, when an exception occurs.
 o getPortNumber()
Gets the port number.
 o loop()
Loops forever, listening for and accepting connections from clients.
 o printUsage(String)
Prints usage information for user upon a start failure.
 o processCommandLine(String[])
Processes the possible commandline arguments (port number).
 o setPortNumber(int)
Sets the port number.

Variables

 o DEFAULT_PORT
 public static final int DEFAULT_PORT
The default port of the server.

 o portNumber
 protected int portNumber
The port number of the server.

 o listenSocket
 protected ServerSocket listenSocket
The server socket.

Constructors

 o Server
 public Server(String args[])
Creates a server socket to listen for connection requests. Starts the listening loop. The given arguments are assumed to be the command line arguments. They are processed first.

Parameters:
args - The command line arguments. Usage: java Server [port].

Methods

 o createMessageHandlers
 public abstract MessageHandler createMessageHandlers(ConnectionManager connectionManager,
                                                      MessageHandler rootHandler)
Creates the message handlers for the server. Must be overriden in subclasses.

Parameters:
connectionManager - The connection manager that deliveres messages.
rootHandler - The (previous) root handler that must be given as a successor for the innermost handler.
 o printUsage
 protected void printUsage(String errorMsg)
Prints usage information for user upon a start failure.

 o processCommandLine
 protected void processCommandLine(String args[])
Processes the possible commandline arguments (port number).

Parameters:
args - The command line arguments. Usage: java Server [port].
 o fail
 private static void fail(Exception e,
                          String msg)
Exit with an error message, when an exception occurs.

 o loop
 private void loop()
Loops forever, listening for and accepting connections from clients. For each connection, creates a ServerThread object to handle communication through the new Socket.

 o setPortNumber
 public void setPortNumber(int n)
Sets the port number.

 o getPortNumber
 public int getPortNumber()
Gets the port number.


All Packages  Class Hierarchy  This Package  Previous  Next  Index