         "verbose" => state.opts.verbose,
     }
     case check_auth(json, connect_json, state.opts.auth) do
-      {:ok, to_send} ->
+      {:noreply, to_send} ->
         if to_send["tls_required"] && false do
           opts = []
           IO.puts "starting SSL handshake:..."
           res = :ssl.connect(state.sock, opts, state.timeout)
           IO.puts "done: #{inspect(res)}"
-          {:ok, port} = res
+          {:noreply, port} = res
           state = %{state | sock: port}
         end
         connect(self(), connect_json)

  def msg(self, subject, sid, reply_queue, what) do
    send self, {:command, {:msg, subject, sid, reply_queue, what}}
  end
  def handle_info({:command, cmd}, %{sock: socket} = state) do
    pack = Nats.Parser.encode(cmd)
    case :gen_tcp.send(socket, pack) do  # :ssl.send(socket, pack) do # 
      :ok -> :ok # IO.puts "sent #{inspect(pack)}..."
      {:error, :closed} -> IO.puts "socket closed: ignoring for NOW!!"
      oops -> IO.puts "NATS send unexpected result: #{inspect(oops)}"
    end
    {:noreply, state}
  end
  def handle_info({:tcp_closed, sock}, state) do
    IO.puts ("tcp_closed: #{inspect(sock)}")
    { :noreply, state }
  end
  def handle_info({:tcp_error, sock, reason}, state) do
    IO.puts ("tcp_closed: #{inspect(sock)}: #{reason}")
    { :noreply, state }
  end
  def handle_info({:tcp_passive, sock}, state) do
    IO.puts ("tcp_passive: #{inspect(sock)}")
    { :noreply, state }
  end
  def handle_info({:tcp, _sock, data}, state) do
#    IO.puts ("tcp: #{inspect(data)}")
    val = Nats.Parser.parse(state.ps, data)
#    IO.puts "received NATS message: #{inspect(val)}"
    case val do
      {:ok, msg, rest, nps} -> handle_packet(%{state | ps: nps}, msg)
      other -> nats_err(state,
                        "received a bad parser result: #{inspect(other)}")
    end
  end
  def handle_info({:ssl, _sock, data}, state) do
#    IO.puts ("tcp: #{inspect(data)}")
    val = Nats.Parser.parse(state.ps, data)
#    IO.puts "received NATS message: #{inspect(val)}"
    case val do
      {:ok, msg, rest, nps} -> handle_packet(%{state | ps: nps}, msg)
      other -> nats_err(state,
                        "received a bad parser result: #{inspect(other)}")
    end
  end
  defp handle_packet(state, msg) do
    case msg do
      {:info, json} -> nats_info(state, json)
      {:connect, json} -> nats_connect(state, json)

                         host: @default_host, port: @default_port,
                         socket_opts: [:binary, active: true]},
                 ps: nil}
  def start_link do start_link(@default_host, @default_port) end
  def start_link(host, port \\ @default_port) do
    state = @start_state
    state = %{state | opts: %{state.opts | host: host, port: port}}
