   (try
     (.readLine in)
     (catch java.net.SocketTimeoutException e
-      nil)))
+      :timeout)))
 
 (defn connect
   ([] (connect *host* *port*))

               (.setSoTimeout 1000))]
       {:socket s
        :in (BufferedReader. (InputStreamReader. (.getInputStream s)))
        :out (.getOutputStream s)})))

(defmacro with-connection [s & body]
  `(let [~s (connect)]

    (.write out (.getBytes (str command "\n")))
    (.flush out)))

(defn found? [pattern lines]
  (some (partial re-find pattern) lines))

(defn expect
  ([socket pattern] (expect socket pattern (or *timeout* 0)))
  ([socket pattern timeout]
     (.setSoTimeout (:socket socket) timeout)
     (let [in (:in socket)]
       (loop [line (socket-read-line in)]
         (swap! (:received socket) conj (if (= :timeout line)
                                          ""
                                          line))
         (if (found? pattern @(:received socket))
           true
           (if (= :timeout line)
             (join "\n" @(:received socket))
             (recur (socket-read-line in))))))))

(defmethod assert-expr 'received? [msg form]
  (let [socket (nth form 1)
