anchor.diff:            receiver_monitor = undefined
            }).
   
  +-type(error() :: {'error', term()}).
  +
   -type(connection() :: pid()).
   
   start_link() ->
       gen_fsm:start_link(?MODULE, [], []).
   
  --spec(connect(connection(), address(), client_id()) -> ok).
  +-spec(connect(connection(), address(), client_id()) -> ok | error()).
   connect(Conn, Address, ClientId) ->
       connect(Conn, Address, ClientId, []).
   
   -spec(connect(connection(),
                 address(),
                 client_id(),
  -              [connect_option() | {'receiver', pid()}]) -> ok).
  +              [connect_option() | {'receiver', pid()}]) -> ok | error()).
   connect(Conn, Address, ClientId, ConnectOpts0) ->
       Connect = #connect{ client_id = iolist_to_binary([ClientId]) },
       Receiver = proplists:get_value(receiver, ConnectOpts0, self()),
  
positive.code:     ok = gen_tcp:send(S, mqtt_framing:serialise(Frame)),
      ok.
  
  %% Record the fact of an RPC and send the frame with the correct id.
  rpc(S0, Req, From) ->
      #state{ id_counter = Id,
              rpcs = RPC0 } = S0,
      RPC1 = gb_trees:insert(Id, From, RPC0),
      write(S0, with_id(Id, Req)),
      S0#state{ id_counter = Id + 1, rpcs = RPC1 }.
  
  
negative.code: 
  %% worth putting specs on these?
  
  unopened({open, Socket, Receiver, Connect}, _From,
           S0 = #state{ socket = undefined }) ->
      Monitor = monitor(process, Receiver),
      S = S0#state{ socket = Socket,
  