anchor.diff:  
   %% Receive packets until a full message is received,
   recv(Bin, #transport{frag = Head} = S) ->
  -    case rcv(Head, Bin) of
  +    case acc(Head, Bin) of
           {Msg, B} ->         %% have a complete message ...
               message(recv, Msg, S#transport{frag = B});
           Frag ->              %% read more on the socket
  
positive.code:          module :: module() | undefined}).
  
  -type length() :: 0..16#FFFFFF. %% message length from Diameter header
  -type size()   :: non_neg_integer().  %% accumulated binary size
  -type frag()   :: {length(), size(), binary(), list(binary())}
                  | binary().
  
  -type connect_option() :: {raddr, inet:ip_address()}
  
negative.code:                                                      flush = false}))
      end.
  
  %% acc/2
  
  %% Know how many bytes to extract.
  acc([Len | Acc], Bin) ->
      acc1(Len, <<Acc/binary, Bin/binary>>);
  
  %% Or not.
  acc(Head, Bin) ->
      acc(<<Head/binary, Bin/binary>>).
  
  %% acc1/3
  
  %% Extract a message for which we have all bytes.
  acc1(Len, Bin)
    when Len =< byte_size(Bin) ->
      <<Msg:Len/binary, Rest/binary>> = Bin,
      {Msg, Rest};
  
  %% Wait for more packets.
  acc1(Len, Bin) ->
      [Len | Bin].
  
  %% acc/1
  
  %% The Message Length isn't even sufficient for a header. Chances are
  %% things will go south from here but if we're lucky then the bytes we
  %% have extend to an intended message boundary and we can recover by
  %% simply receiving them. Make it so.
  acc(<<_:1/binary, Len:24, _/binary>> = Bin)
    when Len < 20 ->
      {Bin, <<>>};
  
  %% Know the message length.
  acc(<<_:1/binary, Len:24, _/binary>> = Bin) ->
      acc1(Len, Bin);
  
  %% Not even 4 bytes yet.
  acc(Bin) ->
      Bin.
  
  %% bin/1
  
  bin([_ | Bin]) ->
      Bin;
  
  bin(Bin) ->
      Bin.
  
  %% flush/1
  