   (:require [com.stuartsierra.component :as component]
             [clojure.java.io :as io]
             [inlein.daemon.read-script :as rs])
-  (:import (java.net ServerSocket SocketTimeoutException)
+  (:import (java.net ServerSocket SocketTimeoutException InetAddress)
            (java.io BufferedInputStream)
            (com.hypirion.bencode BencodeReader BencodeWriter)))
 

  (start [this]
    (if socket-thread
      this
      (let [sock (doto (ServerSocket. (:port cfg))
                   (.setSoTimeout 100))
            thread (doto (Thread. #(run-server system-atom sock))
                     (.start))]
        (.mkdirs (io/file (:inlein-home cfg)))

              in (-> (.getInputStream client-sock)
                     (BufferedInputStream.)
                     (BencodeReader.))]
    (loop [op (bencode-read in)]
      (if-not op
        nil
        (do
          (println "op request:" op)
          (write-ack out op)
          (let [res (handle-request-errors op in out)]
            (println res)
            (case res
              ::shutdown (.start (Thread. #(swap! system-atom component/stop)))
              (recur (bencode-read in)))))))))

(defn run-server [system-atom server-socket]
  (try
