anchor.diff:              {ok, F, Rest, S0};
           {more, K} ->
               wait_for_more(S0, K);
  -        {error, R} ->
  -            frame_error(self(), R)
  +        Err = {error, _} ->
  +            Err
       end.
   
   wait_for_more(S = #state{ socket = Sock }, K) ->
       inet:setopts(Sock, [{active, once}]),
       receive
           {tcp, Sock, D} -> parse_frame(D, S, K);
  -        {tcp_closed, Sock} -> unexpected_closed(self());
  -        {tcp_error, Sock, Reason} -> socket_error(self(), Reason)
  +        {tcp_closed, Sock} -> {error, unexpected_socket_close};
  +        {tcp_error, Sock, Reason} -> {error, {socket_error, Reason}}
       end.
   
   ask_for_more(S = #state{ socket = Sock }) ->
  
positive.code:                          S2
                   end,
              {reply, ok, opened, S3};
          {ok, #connack{ return_code = Else }, S1} ->
              protocol_error(Else, S1);
          {ok, Else, S1} ->
              protocol_error({unexpected, Else}, S1);
          {error, Reason} ->
              frame_error(Reason, S)
      end.
  
  opened({publish, P0}, S0 = #state{ id_counter = NextId }) ->
  
negative.code: 
  selfsend_frame(Frame) ->
      ok = gen_fsm:send_event(self(), {frame, Frame}).
  
  %% Create a frame given the options (fields, effectively) as an alist
  opts(F, []) ->
  