anchor.diff:          ok -> ok;
           X  -> x({setopts, M, Sock, X})  %% possibly on peer disconnect
       end.
  +
  +%% throttle/1
  +
  +throttle(#transport{throttle_cb = false} = S) ->
  +    recv(<<>>, S);
  +
  +throttle(#transport{throttle_cb = F} = S) ->
  +    throttle(diameter_lib:eval(F), S).
  +
  +%% throttle/2
  +
  +%% Don't ask for more packets as long as there are previously received
  +%% messages to extract.
  +throttle(ok, S) ->
  +    recv(<<>>, S#transport{throttled = false});
  +
  +throttle({ok = T, F}, S) ->
  +    throttle(T, S#transport{throttle_cb = F});
  +
  +%% Ask again after the specified number of milliseconds.
  +throttle({timeout, Tmo}, #transport{} = S) ->
  +    erlang:send_after(Tmo, self(), throttle),
  +    S#transport{throttled = true};
  +
  +throttle({timeout = T, Tmo, F}, S) ->
  +    throttle({T, Tmo}, S#transport{throttle_cb = F});
  +
  +throttle(T, #transport{throttle_cb = F}) ->
  +    ?ERROR({invalid_return, T, F}).
   
   %% portnr/2
   
  
positive.code: %% Reassemble fragmented messages and extract multiple message sent
  %% using Nagle.
  
  recv(Bin, #transport{parent = Pid, frag = Head} = S) ->
      case rcv(Head, Bin) of
          {Msg, B} when is_binary(Msg) ->
              diameter_peer:recv(Pid, Msg),
              recv(B, S#transport{frag = <<>>});
          Frag ->
              S#transport{frag = Frag,
                          flush = false}
      end.
  
  %% rcv/2
  
negative.code:     %% that does nothing but kill us with the parent until call
      %% returns.
      {ok, MPid} = diameter_tcp_sup:start_child(#monitor{parent = Pid}),
      {[SO|TO], Rest} = proplists:split(Opts, [ssl_options,
                                               fragment_timer,
                                               throttle_cb]),
      SslOpts = ssl_opts(SO),
      OwnOpts = lists:append(TO),
      Tmo = proplists:get_value(fragment_timer,
                                OwnOpts,
                                ?DEFAULT_FRAGMENT_TIMEOUT),
      ?IS_TIMEOUT(Tmo) orelse ?ERROR({fragment_timer, Tmo}),
      Throttle = proplists:get_value(throttle_cb, OwnOpts, false),
      Sock = init(T, Ref, Mod, Pid, SslOpts, Rest, Addrs),
      MPid ! {stop, self()},  %% tell the monitor to die
      M = if SslOpts -> ssl; true -> Mod end,
      putr(?REF_KEY, Ref),
      throttle(#transport{parent = Pid,
                          module = M,
                          socket = Sock,
                          ssl = SslOpts,
                          timeout = Tmo,
                          throttle_cb = Throttle});
  %% Put the reference in the process dictionary since we now use it
  %% advertise the ssl socket after TLS upgrade.
  
  