anchor.diff:          {false, false} ->
               gen_tcp:send(Socket, exml:to_iolist(StreamEnd))
       end.
  +
  +do_connect(Address, Port, Opts, OnConnectFun) ->
  +    TimeB = os:timestamp(),
  +    Reply = gen_tcp:connect(Address, Port, Opts),
  +    TimeA = os:timestamp(),
  +    ConnectionTime = timer:now_diff(TimeA, TimeB),
  +    case Reply of
  +        {ok, Socket} ->
  +            OnConnectFun({ok, Socket, ConnectionTime});
  +        {error, _} ->
  +            OnConnectFun(Reply)
  +    end,
  +    Reply.
  
positive.code:     Transport = gen_server:call(Pid, get_transport),
      {ok, Transport}.
  
  send(#client{socket = Socket, ssl = true}, Elem) ->
      ssl:send(Socket, exml:to_iolist(Elem));
  send(#client{rcv_pid=Pid, compress = {zlib, {_,Zout}}}, Elem) ->
      gen_server:cast(Pid, {send_compressed, Zout, Elem});
  send(#client{socket = Socket}, Elem) ->
      gen_tcp:send(Socket, exml:to_iolist(Elem)).
  
  is_connected(#client{rcv_pid = Pid}) ->
      erlang:is_process_alive(Pid).
  
negative.code:     Host = proplists:get_value(host, Args, <<"localhost">>),
      Port = proplists:get_value(port, Args, 5222),
      EventClient = proplists:get_value(event_client, Args),
      OnReplyFun = proplists:get_value(on_reply, Args, fun(_) -> ok end),
      OnRequestFun = proplists:get_value(on_request, Args, fun(_) -> ok end),
      OnConnectFun = proplists:get_value(on_connect, Args, fun(_) -> ok end),
      Address = host_to_inet(Host),
      Opts = [binary, {active, once}],
      {ok, Socket} = do_connect(Address, Port, Opts, OnConnectFun),
      {ok, Parser} = exml_stream:new_parser(),
      {ok, #state{owner = Owner,
                  socket = Socket,
                  parser = Parser,
                  event_client = EventClient,
                  on_reply = OnReplyFun,
                  on_request = OnRequestFun}}.
  
  handle_call(get_transport, _From, State) ->
      {reply, transport(State), State};
  