Skip to content

Instantly share code, notes, and snippets.

@mcroydon
Forked from anonymous/fingure.clj
Last active December 10, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcroydon/4423345 to your computer and use it in GitHub Desktop.
Save mcroydon/4423345 to your computer and use it in GitHub Desktop.
(ns fingure.core
(:gen-class))
(use 'lamina.core 'aleph.tcp 'gloss.core)
(defn response [query]
(println (str "Received a request for " (if (clojure.string/blank? query) "index" 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