Created
February 25, 2014 19:32
-
-
Save certainty/9216046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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