 (defn address [config service]
   (str (:transport config) "://" (:ip config) ":" (service config)))
 
-(defn get-iopub-socket [addr]
-  (let [context (zmq/context 1)]
-    (doto zmq/socket context :pub) (zmq/bind addr)))
-
-(defn get-shell-socket [addr]
-  (let [context (zmq/context 2)]
-    (doto (zmq/socket context :router) (zmq/bind addr))))
-
 (defn uuid [] (str (java.util.UUID/randomUUID)))
-
 
 (def kernel-info-content
   {:protocol_version [4 1]
-   :ipython_version [2 0 0 "dev"]
-   :language_version [1 5 1]
-   :language "clojure"})
+   :ipython_version  [3 1 0 "dev"]
+   :language_version [1 7 0]
+   :language         "clojure"})
 
 
 (defn now []
   "Returns current ISO 8601 compliant date."
   (let [current-date-time (time/to-time-zone (time/now) (time/default-time-zone))]
     (time-format/unparse
-     (time-format/with-zone (time-format/formatters :date-time-no-ms)
-                            (.getZone current-date-time))
-     current-date-time)))
+      (time-format/with-zone (time-format/formatters :date-time-no-ms)
+                             (.getZone current-date-time))
+      current-date-time)))
 
 (defn kernel-info-header [message]
-  (let [header (cheshire/generate-string {:date (get-in message [:header :date])
-                                          :msg_id (uuid)
+  (let [header (cheshire/generate-string {:date     (get-in message [:header :date])
+                                          :msg_id   (uuid)
                                           :username (get-in message [:header :username])
-                                          :session (get-in message [:header :session])
+                                          :session  (get-in message [:header :session])
                                           :msg_type "kernel_info_reply"})]
     header))
 
 (defn send-message-piece [socket msg]
-;  (println "Sending piece " msg)
+  ;  (println "Sending piece " msg)
   (zmq/send socket (.getBytes msg) zmq/send-more))
 
 (defn finish-message [socket msg]
-;  (println "Sending message " msg)
+  ;  (println "Sending message " msg)
   (zmq/send socket (.getBytes msg)))
 
 (defn kernel-info-reply [message socket]
   (let [header (kernel-info-header message)
         parent_header (cheshire/generate-string (:header message))
         metadata (cheshire/generate-string {})
-        content  (cheshire/generate-string kernel-info-content)]
+        content (cheshire/generate-string kernel-info-content)]
     (send-message-piece socket (get-in message [:header :session]))
     (send-message-piece socket "<IDS|MSG>")
     (send-message-piece socket "")

  (let [user-ns (generate-ns)]
    (fn [request]
      (str
       (try
         (binding [*ns* user-ns] (eval (read-string request)))
         (catch Exception e (.getLocalizedMessage e)))))))


(defn configure-shell-handler [shell-socket iopub-socket]


(defn read-until-delimiter [socket]
  (let [preamble (doall (drop-last
                          (take-while (comp not #(= "<IDS|MSG>" %))
                                      (repeatedly #(read-blob socket)))))]
    ;    (println "PREABMLE:" preamble)
    preamble))

(defn new-header [msg_type session-id]
  {:date     (now)
   :msg_id   (uuid)
   :username "kernel"
   :session  session-id
   :msg_type msg_type})

(defn status-content [status]
