NioServer is a multi-client stateful server written in Scala, using Java NIO and delimited continuations.
This project holds the code used in my "Java NIO" series of blog posts.
|Tag||Blog Post||Post Date|
|blog-continuations||Java NIO and Scala Continuations||March 22, 2011|
|blog-decoding||Java NIO for Character Decoding in Scala||March 28, 2011|
|blog-coroutines||Java NIO and Scala Coroutines||April 2, 2011|
|blog-write||Java NIO for Writing||April 8, 2011|
|blog-complete||Java NIO Complete Scala Server||April 15, 2011|
|blog-executor||Multithread Coroutine Scheduler||July 19, 2011|
Compiling and Running with Ant
The files are in the standard layout, with source files under
To compile using
build.xml and ant, you must set up a
scala-current that points to the main directory
of your installed copy of scala. Once you have done that, you can use the
following command to compile the application and create a release directory
for it that includes a startup script:
ant build relbin
The following command (with the appropriate
value for the version number
will run EchoServer:
This command will run ThreeQuestionsServer:
If you get an error about port in use, try changing the port value in
src/main/scala/NioServer.scala and recompiling.
Once the server has started without errors, telnet to it from another window:
telnet localhost 1234
When you type into the telnet window and press enter, your text should be echoed back to you.
Compiling and Running without Ant
To compile without using ant,
and run this command:
scalac -P:continuations:enable *.scala net/jimmc/*/*.scala
You can run the test server from the same directory with this command:
Or you can run the ThreeQuestionsServer with this command:
From this point on, see the instructions in the previous section starting with what to do about a port-in-use error.
Cleanup with Ant
You can delete the old files with this command:
The above command will delete the
build folder, but not
releases folder, which is where
puts its results. If you want to delete that folder you must do so manually.
Cleanup without Ant
src/main/scala directory, use this command:
rm *.class net/jimmc/*/*.class