Class Server

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--Server
All Implemented Interfaces:
java.lang.Runnable

public class Server
extends java.lang.Thread

Name: Server
Desc: This object is designed to listen on a specific port for incomming connections from a nsjc client. One object is spawned per port by the nsjsd application.

This object basically waits for a connection. When it receives one it will attempt to identify the host. It does this by checking the alias records and the host records in the system. If it doesn't find the host/alias in the list of records then it will refuse the connection. If it accepts the connection then it will launch a Connection object to handle the transmission of the data.

It is important to note that this object won't actually start listening for connections until it is 'started'. Because this object extends Threads, call the 'run' method. That will launch an asynchronise thread and start the Server object listening on the port.

author: viaggi@nietzsche.net


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Server(int intPort, nsjsd nsjParent)
          Name: Server
          Desc: The constructor of the Server object.
 
Method Summary
 void fail(java.lang.Exception exc, java.lang.String strMsg)
          Name: fail
          Desc: Calls the nsjsd parent's fail method.
 java.lang.Thread getThread()
          Name: get Thread
          Desc: This function will return the running thread as an object.
 void run()
          Name: run
          Desc: This function is an over-riding method for implementing Threads.
 void writelog(java.lang.String strMsg)
          Name: write log
          Desc: Calls the nsjsd parent's write log method.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, 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
 

Constructor Detail

Server

public Server(int intPort,
              nsjsd nsjParent)
Name: Server
Desc: The constructor of the Server object. This takes as parameters the port it should listen on and the nsjsd Parent which holds information regarding the Hosts/Aliases and log files.

Parameters:
intPort - --> int, the port to listen on
nsjParent - --> najsd, the Parent which hold the configuration information
Method Detail

getThread

public java.lang.Thread getThread()
Name: get Thread
Desc: This function will return the running thread as an object. If it works during the while routine.

Returns:
Thread --> the current thread running this object

writelog

public void writelog(java.lang.String strMsg)
Name: write log
Desc: Calls the nsjsd parent's write log method.

Parameters:
strMsg - --> String, the message to write to the log file

fail

public void fail(java.lang.Exception exc,
                 java.lang.String strMsg)
Name: fail
Desc: Calls the nsjsd parent's fail method.

Parameters:
exc - --> Exception, the Exception to report on
strMsg - --> String, the message to report

run

public void run()
Name: run
Desc: This function is an over-riding method for implementing Threads. It will start the Socket listening and process any incomming messages.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread