Class NetLogServer

java.lang.Object
  extended byjava.lang.Thread
      extended byNetLogServer
All Implemented Interfaces:
Runnable

public class NetLogServer
extends Thread

The server end of the remote logging software. At it's simpliest, the server listens for connections on the specified port, and when a client connects, it takes the messages the client sends and saves them to a file. The server can listen for multiple connections and handling logging for several clients. There can be multiple files or a single file for all the output. Usually, each line of the output contains the hostname, the date, and the actual log message. Depending on the config file, selections of host(s) can have their own log file. To implement the basic logging functionality, the class wraps the LocalDrinkLogger class. TODO: For now, all logging will be done to a single file. TODO: Allow for named streams. The server makes a list of what streams are TODO: available. Clients can subscribe to those streams.

Version:
$Revision: #7 $
Author:
Kevin Thompson [antiduh@csh.rit.edu]

Field Summary
private  Socket client
          The socket that is connected to the client, from which we read our the messages the client is sending to us.
static int DEFAULT_PORT
          The port that this server normally listens on.
private  String ipAddy
          The IP address of the host we are logging for.
private static ServerSocket listener
          The ServerSocket where all incoming clients connect to.
private  DrinkLoggerSpec log
          The log an individual session uses to write the actual message.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NetLogServer(DrinkLoggerSpec log, Socket socket)
          Set up an individual session of logging.
 
Method Summary
static void main(String[] args)
          The entry point for the program.
 void run()
          Actually do something useful.
 
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
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The port that this server normally listens on.

See Also:
Constant Field Values

listener

private static ServerSocket listener
The ServerSocket where all incoming clients connect to. All incoming data will originate from here.


log

private DrinkLoggerSpec log
The log an individual session uses to write the actual message.


client

private Socket client
The socket that is connected to the client, from which we read our the messages the client is sending to us.


ipAddy

private String ipAddy
The IP address of the host we are logging for. This is used when logging to show who the message was sent from.

Constructor Detail

NetLogServer

public NetLogServer(DrinkLoggerSpec log,
                    Socket socket)
Set up an individual session of logging. Each session has a reference to a log to print to and a to a client socket to read from.

Parameters:
log - The DrinkLoggerSpec that we actually print to.
socket - The client whose messages we are logging.
Method Detail

main

public static void main(String[] args)
The entry point for the program. For now, the main method starts the listening server socket and creates the _single_ LocalDrinkLogger object. From there, the main method will spawn new instances of this class to handle individual sessions. Each session is passed a reference to the DrinkLoggerSpec it will use to actually write the logs.

Parameters:
args - The command line arguments, which are ignored. All run-time configuration info is read out of the config file

run

public void run()
Actually do something useful. Read a single line from the client, prepend the IP address of the host, then print it to the log.