   (:import  (java.net ServerSocket Socket InetAddress)
             (java.io PushbackReader BufferedReader InputStreamReader
                      PrintWriter    BufferedWriter OutputStreamWriter
-                     DataInputStream  BufferedInputStream
-                     DataOutputStream BufferedOutputStream)
+                     DataInputStream  BufferedInputStream  InputStream
+                     DataOutputStream BufferedOutputStream OutputStream)
             (joptsimple OptionParser OptionSet OptionException))
   (:gen-class))
 

  (fn [dba #^Socket socket]
    (try
      (with-open [socket socket
                  out    (init-out socket)
                  in     (init-in  socket)]
        (.setKeepAlive socket true)
        (loop []
          (if (try


(def- binary-handler
  (generic-handler
    (fn [#^OutputStream os] (DataOutputStream. (BufferedOutputStream. os)))
    (fn [#^InputStream is] (DataInputStream.  (BufferedInputStream. is)))
    (fn [#^DataInputStream in eof-val] (io/dis-deserialize in io/eof))
    (fn [#^DataOutputStream out resp]  (io/dos-serialize out resp))))

(def- bert-handler
  (generic-handler
    (fn [#^OutputStream os] (DataOutputStream. (BufferedOutputStream. os)))
    (fn [#^InputStream is] (DataInputStream.  (BufferedInputStream.  is)))
    (fn [#^DataInputStream in eof-val] (io/dis-berp-decode in io/eof))
    (fn [#^DataOutputStream out resp]  (io/dos-berp-encode out resp))))

