Package com.sun.akuma
Class EchoServer
- java.lang.Object
-
- com.sun.akuma.Daemon
-
- com.sun.akuma.NetworkServer
-
- com.sun.akuma.EchoServer
-
public class EchoServer extends NetworkServer
Sample echo server.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.sun.akuma.Daemon
Daemon.WithoutChdir
-
-
Field Summary
-
Fields inherited from class com.sun.akuma.NetworkServer
arguments
-
-
Constructor Summary
Constructors Constructor Description EchoServer(java.lang.String[] args)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.net.ServerSocket
createServerSocket()
Creates a boundServerSocket
that will be shared by all worker processes.protected void
forkWorkers(JavaVMArguments args)
Forks the worker thread with the given JVM args.protected void
frontend()
Front-end.static void
main(java.lang.String[] args)
protected boolean
shouldBeDaemonized()
Daemonize if something is given as arguments.protected void
worker(java.net.ServerSocket ss)
Worker thread main code.-
Methods inherited from class com.sun.akuma.NetworkServer
forkWorkerThreads, run, worker
-
Methods inherited from class com.sun.akuma.Daemon
all, chdirToRoot, closeDescriptors, daemonize, daemonize, getCurrentExecutable, init, init, isDaemonized, selfExec, writePidFile
-
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
shouldBeDaemonized
protected boolean shouldBeDaemonized()
Daemonize if something is given as arguments.- Overrides:
shouldBeDaemonized
in classNetworkServer
-
frontend
protected void frontend() throws java.lang.Exception
Description copied from class:NetworkServer
Front-end.- Overrides:
frontend
in classNetworkServer
- Throws:
java.lang.Exception
-
forkWorkers
protected void forkWorkers(JavaVMArguments args) throws java.lang.Exception
Description copied from class:NetworkServer
Forks the worker thread with the given JVM args. The implementation is expected to modify the arguments to suit their need, then call intoNetworkServer.forkWorkerThreads(JavaVMArguments, int)
.- Specified by:
forkWorkers
in classNetworkServer
- Throws:
java.lang.Exception
-
createServerSocket
protected java.net.ServerSocket createServerSocket() throws java.lang.Exception
Description copied from class:NetworkServer
Creates a boundServerSocket
that will be shared by all worker processes. This method is called in the frontend process.- Specified by:
createServerSocket
in classNetworkServer
- Throws:
java.lang.Exception
-
worker
protected void worker(java.net.ServerSocket ss) throws java.lang.Exception
Description copied from class:NetworkServer
Worker thread main code.- Specified by:
worker
in classNetworkServer
- Parameters:
ss
- The server socket that the frontend process created.- Throws:
java.lang.Exception
-
-