anchor.diff:  init({Host, Port, Resource}) ->
     {ok, Socket} = gen_tcp:connect(Host, Port, [binary, {reuseaddr, true}, {packet, raw}] ),
   
  -  Handshake = wsecli_handshake:build(Resource, Host, Port),
  -  Request = wsecli_http:to_request(Handshake#handshake.message),
  +  Handshake = wsock_handshake:open(Resource, Host, Port),
  +  Request = wsock_http:encode(Handshake#handshake.message),
   
     ok = gen_tcp:send(Socket, Request),
     {ok, connecting, #data{ socket = Socket, handshake = Handshake}}.
  
positive.code: %% @hidden
  -spec handle_info({tcp, Socket::gen_tcp:socket(), Data::binary()}, connecting, #data{}) -> {next_state, atom(), #data{}}.
  handle_info({tcp, Socket, Data}, connecting, StateData) ->
    Response = wsecli_http:from_response(Data),
    case wsecli_handshake:validate(Response, StateData#data.handshake) of
      true ->
        spawn(StateData#data.cb#callbacks.on_open),
        {next_state, open, StateData};
      false ->
        {stop, failed_handshake, StateData}
    end;
  
  handle_info({tcp, Socket, Data}, open, StateData) ->
    {Messages, State} = case StateData#data.fragmented_message of
      undefined ->
        {wsecli_message:decode(Data), StateData};
      Message ->
        {wsecli_message:decode(Data, Message), StateData#data{fragmented_message = undefined}}
    end,
    NewStateData = process_messages(Messages, State),
    {next_state, open, NewStateData};
  
  handle_info({tcp, Socket, Data}, closing, StateData) ->
    [Message] = wsecli_message:decode(Data),
    case Message#message.type of
      close ->
        % if we don't receive a tcp_closed message, move to closed state anyway
  
negative.code:   {next_state, open, StateData};
  
  open({send, Data}, StateData) ->
    Message = wsock_message:encode(Data, [mask, text]),
    case gen_tcp:send(StateData#data.socket, Message) of
      ok ->
        ok;
  