nl.knowledgeplaza.util.io
Class EchoServer

java.lang.Object
  extended by nl.knowledgeplaza.util.io.EchoServer

public class EchoServer
extends Object

This is a base class for easy server sockets: 1. extend this class (MyServer, with default port or something for the constructor) 2. override the handleConnection(Socket socket, BufferedReader reader, PrintWriter writer) 3. Create a main with "new MyServer(port).startServer(false);"

Version:
$Revision: 1.2 $

Field Summary
protected  int iPort
           
protected  org.apache.log4j.Logger log4j
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
EchoServer(int port)
           
 
Method Summary
protected  void handleConnection(Socket socket)
           
protected  void handleConnection(Socket socket, BufferedReader reader, PrintWriter writer)
           
static void main(String[] args)
          Open a server on port 12345 or what is specified at the commandline
protected  void service()
           
 void startServer()
          Create the service detached
 void startServer(boolean detach)
          Create the service
 void stopServer()
          Stop the service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

log4j

protected org.apache.log4j.Logger log4j

iPort

protected int iPort
Constructor Detail

EchoServer

public EchoServer(int port)
Method Detail

service

protected void service()

startServer

public void startServer()
Create the service detached


startServer

public void startServer(boolean detach)
Create the service


stopServer

public void stopServer()
Stop the service


handleConnection

protected void handleConnection(Socket socket)
                         throws IOException
Throws:
IOException

handleConnection

protected void handleConnection(Socket socket,
                                BufferedReader reader,
                                PrintWriter writer)
                         throws IOException
Throws:
IOException

main

public static void main(String[] args)
Open a server on port 12345 or what is specified at the commandline

Parameters:
args -


Copyright © 2012 KnowledgePlaza. All Rights Reserved.