Skip to content

Instantly share code, notes, and snippets.

@certainty
Created February 25, 2014 19:32
Show Gist options
  • Save certainty/9216046 to your computer and use it in GitHub Desktop.
Save certainty/9216046 to your computer and use it in GitHub Desktop.
(ns net_protocols.examples.console_server.client
(:use [net_protocols.streams.base :as stream]
[net_protocols.streams.tcp :as tcp]
[net_protocols.control.core :as ctrl]))
(defn authenticate [stream username password]
(ctrl/challenge-response stream #"Username" (str username "\n"))
(ctrl/challenge-response stream #"Password" (str password "\n")))
(defn get-version []
(with-open [stream (tcp/connect "localhost" 12345)]
(authenticate stream "bob" "bob")
(ctrl/challenge-response stream #"console>>" "version\n")
(clojure.string/trim (ctrl/read-until stream \newline))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment