anchor.diff:  %% states
   -export([unopened/3]).
   
  --type(connection_state() :: 'unopened').
  -
   -include("include/types.hrl").
   
   -record(state, {
  
positive.code:           frame_buf = <<>>
           }).
  
  start_link() ->
      gen_fsm:start_link(?MODULE, [], []).
  
  connect(Conn, Host, Port, ConnectFrame) ->
      {ok, Sock} = gen_tcp:connect(Host, Port,
                                   [{active, false},
                                    binary]),
      open(Conn, Sock, ConnectFrame).
  
  %% NB this assumes that the calling process controls the socket
  open(Conn, Sock, ConnectFrame) ->
      ok = gen_tcp:controlling_process(Sock, Conn),
      gen_fsm:sync_send_event(Conn, {open, Sock, ConnectFrame}).
  
  
  %%% gen_fsm callbacks
  
  
negative.code:     {ok, unopened, #state{}}.
  
  %% states
  
  %% worth putting specs on these?
  
  unopened({open, Socket, Connect}, From,
           S0 = #state{ socket = undefined }) ->
  