anchor.diff:         Dir == recv ->
       actions(As, Dir, S);
   
  -actions([Bin | As], send = Dir, #transport{} = S)
  -  when is_binary(Bin) ->
  -    actions(As, Dir, send(Bin, S));
  -
  -actions([Bin | As], recv = Dir, #transport{parent = Pid} = S)
  -  when is_binary(Bin) ->
  -    diameter_peer:recv(Pid, Bin),
  +actions([Msg | As], send = Dir, S)
  +  when is_binary(Msg);
  +       is_record(Msg, diameter_packet) ->
  +    actions(As, Dir, send(Msg, S));
  +
  +actions([Msg | As], recv = Dir, #transport{parent = Pid} = S)
  +  when is_binary(Msg);
  +       is_record(Msg, diameter_packet) ->
  +    diameter_peer:recv(Pid, Msg),
       actions(As, Dir, S);
   
   actions([{defer, Tmo, Acts} | As], Dir, S) ->
  
positive.code: message(ack, _, #transport{message_cb = false} = S) ->
      S;
  
  message(Dir, #diameter_packet{bin = Bin}, S) ->
      message(Dir, Bin, S);
  
  message(Dir, Bin, #transport{message_cb = CB} = S) ->
      recv(<<>>, actions(cb(CB, Dir, Bin), Dir, S)).
  
  %% actions/3
  
  
negative.code: 
  %% send/2
  
  send(Msg, #monitor{socket = Sock, module = M, transport = TPid, ack = B}) ->
      send1(M, Sock, Msg),
      B andalso (TPid ! Msg);
  
  send(Msg, #transport{socket = Sock, module = M, send = false} = S) ->
      send1(M, Sock, Msg),
      message(ack, Msg, S);
  
  %% Send from the monitor process to avoid deadlock if both the
  %% receiver and the peer were to block in send.
  send(Msg, #transport{send = Pid} = S) ->
      Pid ! Msg,
      S.
  
  %% send1/3
  
  send1(Mod, Sock, #diameter_packet{bin = Bin}) ->
      send1(Mod, Sock, Bin);
  
  send1(Mod, Sock, Bin) ->
      case send(Mod, Sock, Bin) of
  