anchor.diff:                             _MaskKey:4/binary,
                              _/binary-unit:8>> = PartFrame,
                     Acc) ->
  -
       ok = mochiweb_socket:setopts(Socket, [{packet, 0}, {active, once}]),
       receive
           {tcp_closed, _} ->
  
positive.code: 
  payload_length(N) ->
      case N of
          N when N =< 125 -> << N:7 >>;
          N when N =< 16#ffff -> << 126:7, N:16 >>;
          N when N =< 16#7fffffffffffffff -> << 127:7, N:64 >>
      end.
  
  
  
negative.code:     Body(Payload, State, ReplyChannel).
  
  send(Socket, Payload, hybi) ->
      Prefix = <<1:1, 0:3, 1:4, (payload_length(iolist_size(Payload)))/binary>>,
      mochiweb_socket:send(Socket, [Prefix, Payload]);
  send(Socket, Payload, hixie) ->
      mochiweb_socket:send(Socket, [0, Payload, 255]).
  
  upgrade_connection(Req, Body) ->
      case make_handshake(Req) of
          {Version, Response} ->
              Req:respond(Response),
              Socket = Req:get(socket),
              ReplyChannel = fun (Payload) ->
                  ?MODULE:send(Socket, Payload, Version)
              end,
              Reentry = fun (State) ->
                  ?MODULE:loop(Socket, Body, State, Version, ReplyChannel)
              end,
              {Reentry, ReplyChannel};
          _ ->
              mochiweb_socket:close(Req:get(socket)),
              exit(normal)
  