   (proxy [SimpleChannelInboundHandler]
     []
     (channelActive [^ChannelHandlerContext ctx]
-      (info "active")
       ;(.writeAndFlush ctx (Unpooled/copiedBuffer "Netty Rocks1" CharsetUtil/UTF_8))
       )
     (channelRead0 [^ChannelHandlerContext ctx ^ByteBuf in]

(ns clj-tcp.client
   (:require [clojure.tools.logging :refer [info error]]
             [clj-tcp.codec :refer [byte-decoder byte-encoder buffer->bytes]]
             [clojure.core.async :refer [chan >!! go >! <! <!! thread]])
   (:import  
            [java.net InetSocketAddress]
            [java.util.concurrent Future]
            [io.netty.util CharsetUtil]
            [io.netty.buffer Unpooled ByteBuf ByteBufUtil]
            [io.netty.channel SimpleChannelInboundHandler ChannelHandler ChannelInboundHandlerAdapter ChannelInitializer ChannelInitializer ChannelHandlerContext ChannelFutureListener]
            [io.netty.channel.nio NioEventLoopGroup]
            [io.netty.util.concurrent GenericFutureListener]
            [io.netty.bootstrap Bootstrap]
            [io.netty.channel.socket.nio NioSocketChannel]))

(defrecord Client [group channel-f write-ch read-ch error-ch])

(defn close-client [{:keys [group channel-f]}]
  (-> channel-f .channel .closeFuture .sync))

(defn close-all [{:keys [group] :as conf}]
  (close-client conf)

               (try
                  (close-client client)
                  (catch Exception e (do
                                       (error (str "Close listener error " e)  e)
                                       (>!! error-ch [e nil])
                                       )))))))
           

(defn write! [{:keys [write-ch]} v]
