anchor.diff:      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} = gen_tcp:connect(Address, Port, Opts),
  +    {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}}.
  +                event_client = EventClient,
  +                on_reply = OnReplyFun,
  +                on_request = OnRequestFun}}.
   
   handle_call(get_transport, _From, State) ->
       {reply, transport(State), State};
  
positive.code:         {false, false} ->
              gen_tcp:send(Socket, exml:to_iolist(StreamEnd))
      end.
  
negative.code:                 parser,
                  ssl = false,
                  compress = false,
                  event_client,
                  on_reply,
                  on_request}).
  
  %%%===================================================================
  %%% API
  