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
-
DEFAULT_PORT
- The default port of the server.
-
listenSocket
- The server socket.
-
portNumber
- The port number of the server.
-
Server(String[])
- Creates a server socket to listen for connection requests.
-
createMessageHandlers(ConnectionManager, MessageHandler)
- Creates the message handlers for the server.
-
fail(Exception, String)
- Exit with an error message, when an exception occurs.
-
getPortNumber()
- Gets the port number.
-
loop()
- Loops forever, listening for and accepting connections from clients.
-
printUsage(String)
- Prints usage information for user upon a start failure.
-
processCommandLine(String[])
- Processes the possible commandline arguments (port number).
-
setPortNumber(int)
- Sets the port number.
DEFAULT_PORT
public static final int DEFAULT_PORT
- The default port of the server.
portNumber
protected int portNumber
- The port number of the server.
listenSocket
protected ServerSocket listenSocket
- The server socket.
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]
.
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.
printUsage
protected void printUsage(String errorMsg)
- Prints usage information for user upon a start failure.
processCommandLine
protected void processCommandLine(String args[])
- Processes the possible commandline arguments (port number).
- Parameters:
- args - The command line arguments. Usage:
java Server [port]
.
fail
private static void fail(Exception e,
String msg)
- Exit with an error message, when an exception occurs.
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.
setPortNumber
public void setPortNumber(int n)
- Sets the port number.
getPortNumber
public int getPortNumber()
- Gets the port number.
All Packages Class Hierarchy This Package Previous Next Index