Skip to content

jimmc/nioserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NioServer

NioServer is a multi-client stateful server written in Scala, using Java NIO and delimited continuations.

Blog

This is the code used in my "Java NIO" blog post at http://jim-mcbeath.blogspot.com/2011/03/java-nio-and-scala-continuations.html

Compiling and Running with Ant

The files are in the standard layout, with source files under src/main/scala. To compile using build.xml and ant, you must set up a symlink called 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

You can run the test program with this command (with the appropriate value for the version number N.N.N):

release/nioserver-N.N.N/bin/nioserver

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, cd into src/main/scala and run this command:

scalac -P:continuations:enable *.scala

You can run the test server from the same directory with this command:

scala NioServer

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:

ant clean

The above command will delete the build folder, but not the releases folder, which is where ant relbin puts its results. If you want to delete that folder you must do so manually.

Cleanup without Ant

From the src/main/scala directory, use this command:

rm *.class

About

Scala multi-client stateful server using Java NIO and Scala continuations

Resources

License

Stars

Watchers

Forks

Packages

No packages published