[ANN] Example async TCP echo client/server using Java 7 NIO.2.

518 views
Skip to first unread message

David James

unread,
Dec 19, 2013, 9:10:34 PM12/19/13
to clo...@googlegroups.com
An asynchrononous TCP echo client/server in Clojure using Java 7 NIO.2.

As I've been diving into async libraries in Java and Clojure, I thought it would be nice to make a simple example with the Java 7 NIO.2 async classes. I'm sure there is room for improvement, so please let me know if you have feedback or suggestions.

I find this Clojure version easier to follow than existing Java examples, largely because `proxy` makes the callbacks more compact.

I intentionally kept the callbacks at the top-level, thus avoiding a lot of nesting, which led to some minor callback hell. The scoping is clearer that way, even if the program flow is not. I would expect that different people would have different preferences.

I would be interested to see other ways of handling it (like core.async, perhaps?).

--
David James

Reply all
Reply to author
Forward
0 new messages