anchor.diff:  
   behaviour_info(callbacks) ->
       [{init,1},
  -     {handle_call, 3},
  -     {handle_cast, 2},
  -     {handle_info, 2},
  -     {terminate, 2},
  -     {code_change, 3},
  -     {on_connect, 1},
  -     {on_connect_error, 2},
  -     {on_disconnect, 1},
  -     {on_subscribe, 2},
  -     {on_unsubscribe, 2},
  -     {on_publish, 3}];
  +        {handle_call, 3},
  +        {handle_cast, 2},
  +        {handle_info, 2},
  +        {terminate, 2},
  +        {code_change, 3},
  +        {on_connect, 1},
  +        {on_connect_error, 2},
  +        {on_disconnect, 1},
  +        {on_subscribe, 2},
  +        {on_unsubscribe, 2},
  +        {on_publish, 3}];
   behaviour_info(_Other) ->
       undefined.
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%% State Callbacks
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   connecting(connect, State) ->
  -    #state{host = Host, port = Port, transport={Transport, Opts}} = State,
  +    #state{host = Host, port = Port, transport={Transport, Opts}, client=ClientId, info_fun=InfoFun} = State,
       case Transport:connect(Host, Port, [binary, {packet, raw}|Opts]) of
           {ok, Sock} ->
  -            NewState = State#state{sock=Sock, buffer= <<>>},
  +            NewInfoFun = call_info_fun({connect_out, ClientId}, InfoFun),
  +            NewState = State#state{sock=Sock, buffer= <<>>, info_fun=NewInfoFun},
               send_connect(NewState),
               active_once(Transport, Sock),
               {next_state, waiting_for_connack, NewState};
  
positive.code:     KeepAliveInterval = proplists:get_value(keepalive_interval, Opts, 60),
      RetryInterval = proplists:get_value(retry_interval, Opts, 10),
      ProtoVer = proplists:get_value(proto_version, Opts, ?MQTT_PROTO_MAJOR),
  
      {Transport, TransportOpts} = proplists:get_value(transport, Opts, {gen_tcp, []}),
  
      State = #state{host = Host, port = Port, proto_version=ProtoVer,
  		   username = Username, password = Password, client=ClientId, mod=Mod,
             clean_session=CleanSession, last_will_topic=LWTopic, last_will_msg=LWMsg, last_will_qos=LWQos,
             reconnect_timeout=case ReconnectTimeout of undefined -> undefined; _ -> 1000 * ReconnectTimeout end,
             keepalive_interval=1000 * KeepAliveInterval,
             retry_interval=1000* RetryInterval, transport={Transport, TransportOpts}},
      Res = wrap_res(connecting, init, [Args], State),
      gen_fsm:send_event_after(0, connect),
      Res.
  
negative.code:     ok = inet:setopts(Sock, [{active, once}]);
  active_once(ssl, Sock) ->
      ok = ssl:setopts(Sock, [{active, once}]).
  
  call_info_fun(Info, {Fun, FunState}) ->
      {Fun, Fun(Info, FunState)}.
  