Trivial Non-Blocking Echo Server (Scala+Akka)

Akka is a framework for asynchronous messaging and IO in Scala. A colleague of mine gave it a good recommendation so I thought I’d check it out. It looks very promising although its low-level IO API is not as intuitive as I’d hoped. But, it was very easy to build a simple echo server, the “Hello, World!” of network programming.

Of course, it’s pretty easy to build a blocking socket server in pretty much any language. What I love about Scala+Akka is how easy it is to hide the fact that all of this IO is non-blocking.

Could not embed GitHub Gist 2219531: Not Found

To run:

scala -cp .:/home/rweeks/projects/akka-2.0/lib/akka/akka-actor-2.0.jar TCPServer

To test:

rweeks@foxbat:~/projects/scala-test$ telnet localhost 8080
Connected to localhost.
Escape character is '^]'.
You go first.
You go first.
No, You go first!
No, You go first!
telnet> close
Connection closed.