Class net.NetworkServer
All Packages    This Package    Previous    Next

Class net.NetworkServer

java.lang.Object
   |
   +----net.NetworkServer

public class NetworkServer
extends Object
implements Runnable
This is the base class for network servers. To define a new type of server define a new subclass of NetworkServer with a serviceRequest method that services one request. Start the server by executing:
	new MyServerClass().startServer(port);

clientInput
Buffered stream for reading replies from client.
clientOutput
Stream for printing to the client.
clientSocket
Socket for communicating with client.

NetworkServer()

clientIsOpen()
Return client connection status
close()
Close an open connection to the client.
main(String[])
run()
serviceRequest()
Service one request.
startServer(int)
Start a server on port port.

clientSocket
  public Socket clientSocket
Socket for communicating with client.
clientOutput
  public PrintStream clientOutput
Stream for printing to the client.
clientInput
  public InputStream clientInput
Buffered stream for reading replies from client.

NetworkServer
  public NetworkServer()

close
  public void close()
Close an open connection to the client.

clientIsOpen

  public boolean clientIsOpen()
Return client connection status

run

  public final void run()
startServer
  public final void startServer(int port)
Start a server on port port. It will call serviceRequest() for each new connection.

serviceRequest

  public void serviceRequest()
Service one request. It is invoked with the clientInput and clientOutput streams initialized. This method handles one client connection. When it is done, it can simply exit. The default server just echoes it's input. It is invoked in it's own private thread.

main

  public static void main(String argv[])

All Packages    This Package    Previous    Next