: Class Server

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.shell.server
Class Server

    java.lang.Object
      |
      +--java.lang.Thread
            |
            +--com.dalsemi.shell.server.Server

Direct Known Subclasses:
  FTPServer, SerialServer, TelnetServer

public abstract class Server
extends Thread

A generic server. Servers will listen on some system resource for connection requests. When someone attempts to login, the server spins off a session to handle that login. Servers are designed to be multi-threaded, allowing multiple simultaneous connections.

Field Summary
`protected Vector` | `sessions` List of sessions created by this server.
`protected boolean` | `shutdown` Stops this server when set to true.

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Constructor Summary
`protected` | `Server()` Initializes the server and creates the list of sessions (initially empty).

Method Summary
`protected abstract Session` | `acceptNewSession()` Waits for a connection request.
`void` | `broadcast(String sendThis)` Cycles through the list of know sessions, sending the specified message.
`protected void` | `checkForNewSessions()` Listens for connection requests.
`protected abstract void` | `closeAllPorts()` Cleans up any system resources held by this server.
`String[]` | `getConnectedUsers()` Gets an array of the names of all of the users that are currently connected to this server.
`void` | `run()` Starts the server.
`void` | `sessionEnded(Session session)` Notifies this server that a particular session is ending.
`void` | `shutDown()` Requests that the server stop taking connections and terminate any current sessions.

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### sessions

    protected Vector sessions

  List of sessions created by this server.

### shutdown

    protected boolean shutdown

  Stops this server when set to true.

Constructor Detail

### Server

    protected Server()

  Initializes the server and creates the list of sessions (initially empty).

Method Detail

### run

    public void run()

  Starts the server. This method continuously loops checking for new connections until the `shutdown` field is set to `true`.
  Overrides:
    run in class Thread

### checkForNewSessions

    protected void checkForNewSessions()

  Listens for connection requests. This method blocks until a request is received. Once the new session is created, it is added to the list of known sessions.

### acceptNewSession

    protected abstract Session acceptNewSession()

  Waits for a connection request. This method should block until a request is received. When a request is made, it should create, initialize, and return a new Session to handle that connection.
  Returns:
    a new Session

### shutDown

    public void shutDown()
                  throws IOException

  Requests that the server stop taking connections and terminate any current sessions. Cycles through the list of known sessions, closing down each one and then cleaning up its own system resources.

### sessionEnded

    public void sessionEnded(Session session)

  Notifies this server that a particular session is ending. Removes the closing session from the list of known sessions.
  Parameters:
    `session` - the session that has terminated

### getConnectedUsers

    public String[] getConnectedUsers()

  Gets an array of the names of all of the users that are currently connected to this server.
  Returns:
    user names of all connected users

### broadcast

    public void broadcast(String sendThis)

  Cycles through the list of know sessions, sending the specified message.
  Parameters:
    `sendThis` - message to send to all sessions

### closeAllPorts

    protected abstract void closeAllPorts()
                                   throws IOException

  Cleans up any system resources held by this server.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD