Skip to content

Instantly share code, notes, and snippets.

@sunng87
Created March 16, 2012 06:12
Show Gist options
  • Save sunng87/2048747 to your computer and use it in GitHub Desktop.
Save sunng87/2048747 to your computer and use it in GitHub Desktop.
An echo server example for link
(ns link-test.tcp
(:refer-clojure :exclude [float byte double])
(:use [link core tcp codec]))
(def echo-handler
(create-handler
(on-message [ctx e]
(let [channel (.getChannel ctx)]
(.write channel
(.getMessage e))))))
(defn -main [& args]
(tcp-server 5888 echo-handler
:codec (string :encoding :ascii :delimiter "\r\n"))
(println "server started on 5888"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment