Skip to content

Instantly share code, notes, and snippets.

Created December 31, 2012 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4422217 to your computer and use it in GitHub Desktop.
Save anonymous/4422217 to your computer and use it in GitHub Desktop.
Fingure: hyper-minimal finger server in Clojure.
(ns fingure.core
(:gen-class))
(use 'lamina.core 'aleph.tcp 'gloss.core)
(defn response [query]
(println (count query))
(if (clojure.string/blank? query)
"Greetings from the fingure finger daemon."
(str "Greetings from the fingure finger daemon.\r\nNo information about " query " found.")))
(defn handler [ch client-info]
(receive-all ch
#(enqueue-and-close ch (response %))))
(defn -main[]
(start-tcp-server handler {:port 79, :frame (string :utf-8 :delimiters ["\r\n"])}))
$ finger @localhost
[localhost]
Trying 127.0.0.1...
Greetings from the fingure finger daemon.
$ finger foo@localhost
[localhost]
Trying 127.0.0.1...
Greetings from the fingure finger daemon.
No information about foo found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment