anchor.diff:  decode_len(<<126:7, Len:16, Rest/bytes>>) ->
       {Len, Rest};
   decode_len(<<Len:7, Rest/bytes>>) ->
  -    {Len, Rest}.
  +    case Len of 
  +         127 -> error;
  +         126 -> error;
  +         _ -> {Len, Rest}
  +    end.
   
   %% Local variables:
   %% mode: erlang
  
positive.code:                 host, port, path,
                  sock,
                  headers,
                  raw_buffer = <<>>,
                  buffer = <<>>,
                  op_cont,
                  recv_frames = []}).
  
  %%----------------------------------------------------------------------------
  %% API
  
negative.code:     end.
  
  receive_frame(State = #state{sock = Sock, 
                               data_buffer = Data, 
                               op_cont = Cop,
                               frame_buffer = FrameBuf}) ->
      case recv_data(Sock, Data) of
  	{Op, Payload, 0, RestData}  -> 
  	    receive_frame(State#state{frame_buffer = <<FrameBuf/binary, Payload/binary>>,
  				      data_buffer = RestData,
  				      op_cont = op_cont(Cop, Op)});
  	{Op, Payload, 1, RestData} ->
  	    Opcode = op_cont(Cop, Op),
  	    CompleteFrame = {Opcode, <<FrameBuf/binary, Payload/binary>>},
  	    handle_control(Opcode, Sock),
  	    {CompleteFrame, State#state{frame_buffer = <<>>, data_buffer = RestData}};
  	_ -> {error, State#state{readystate = ?CLOSED, frame_buffer = <<>>, data_buffer = <<>>}}
      end.
  
  handle_control(close, Sock) ->
      gen_tcp:close(Sock);
  handle_control(ping, Sock) ->
      gen_tcp:send(Sock, frame(?OP_PONG,<<>>));
  handle_control(_, _) ->
      ok.
  
  op_cont(Cop, ?OP_CONT) ->
  