anchor.diff:  
   %% setopts/1
   
  -setopts(#transport{socket = Sock, module = M}) ->
  -    setopts(M, Sock).
  -
  -%% setopts/2
  -
  -setopts(M, Sock) ->
  +setopts(#transport{socket = Sock,
  +                   module = M}
  +        = S)->
       case setopts(M, Sock, [{active, once}]) of
  -        ok -> ok;
  -        X  -> x({setopts, M, Sock, X})  %% possibly on peer disconnect
  -    end.
  -
  -%% throttle/1
  -
  -%% Still collecting packets for a complete message: keep receiving.
  -throttle(#transport{throttled = false} = S) ->
  -    recv(S);
  -
  -%% Decide whether to receive another, or whether to accept a message
  -%% that's been received.
  -throttle(#transport{throttle_cb = F, throttled = T} = S) ->
  -    Res = cb(F, T),
  -
  -    try throttle(Res, S) of
  -        #transport{ssl = SB} = NS when is_boolean(SB) ->
  -            throttle(defrag(NS));
  -        #transport{throttled = Msg} = NS when is_binary(Msg) ->
  -            %% Initial incoming message when we might need to upgrade
  -            %% to TLS: wait for reception of a tls tuple.
  -            defrag(NS)
  -    catch
  -        #transport{} = NS ->
  -            recv(NS)
  -    end.
  -
  -%% cb/2
  -
  -cb(false, _) ->
  -    ok;
  -
  -cb(F, B) ->
  -    diameter_lib:eval([F, true /= B andalso B]).
  -
  -%% throttle/2
  -
  -%% Callback says to receive another message.
  -throttle(ok, #transport{throttled = true} = S) ->
  -    throw(S#transport{throttled = false});
  -
  -%% Callback says to accept a received message.
  -throttle(ok, #transport{parent = Pid, throttled = Msg} = S)
  -  when is_binary(Msg) ->
  -    diameter_peer:recv(Pid, Msg),
  -    S;
  -
  -throttle({ok = T, F}, S) ->
  -    throttle(T, S#transport{throttle_cb = F});
  -
  -%% Callback says to accept a received message and acknowledged the
  -%% returned pid with a {request, Pid} message if a request pid is
  -%% spawned, a discard message otherwise. The latter does not mean that
  -%% the message was necessarily discarded: it could have been an
  -%% answer.
  -throttle(NPid, #transport{parent = Pid, throttled = Msg} = S)
  -  when is_pid(NPid), is_binary(Msg) ->
  -    diameter_peer:recv(Pid, {Msg, NPid}),
  -    S;
  -
  -throttle({NPid, F}, #transport{throttled = Msg} = S)
  -  when is_pid(NPid), is_binary(Msg) ->
  -    throttle(NPid, S#transport{throttle_cb = F});
  -
  -%% Callback to accept a received message says to discard it.
  -throttle(discard, #transport{throttled = Msg} = S)
  -  when is_binary(Msg) ->
  -    S;
  -throttle({discard = T, F}, #transport{throttled = Msg} = S)
  -  when is_binary(Msg) ->
  -    throttle(T, S#transport{throttle_cb = F});
  -
  -%% Callback to accept a received message says to answer it with the
  -%% supplied binary.
  -throttle(Bin, #transport{throttled = Msg} = S)
  -  when is_binary(Bin), is_binary(Msg) ->
  -    send(Bin, S),
  -    S;
  -throttle({Bin, F}, #transport{throttled = Msg} = S)
  -  when is_binary(Bin), is_binary(Msg) ->
  -    throttle(Bin, S#transport{throttle_cb = F});
  -
  -%% Callback says to ask again in the specified number of milliseconds.
  -throttle({timeout, Tmo}, S) ->
  -    erlang:send_after(Tmo, self(), throttle),
  -    throw(S);
  -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}).
  -
  -%% defrag/1
  -%%
  -%% Try to extract another message from packets already read before
  -%% another throttling callback.
  -
  -defrag(#transport{frag = Head} = S) ->
  -    case rcv(Head, <<>>) of
  -        {Msg, B} ->
  -            S#transport{throttled = Msg, frag = B};
  -        _ ->
  -            S#transport{throttled = true}
  +        ok -> S;
  +        X  -> x({setopts, Sock, M, X})  %% possibly on peer disconnect
       end.
   
   %% portnr/2
  
positive.code: %% Transition monitor state.
  
  %% Outgoing message.
  m(Bin, #monitor{} = S)
    when is_binary(Bin) ->
      send(Bin, S),
      S;
  
negative.code:     %% Since accept/connect might block indefinitely, spawn a process
      %% that kills us with the parent until call returns, and then
      %% sends outgoing messages.
      {[SO|TO], Rest} = proplists:split(Opts, [ssl_options,
                                               fragment_timer]),
      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}),
      {ok, MPid} = diameter_tcp_sup:start_child(#monitor{parent = Pid}),
      Sock = init(T, Ref, Mod, Pid, SslOpts, Rest, Addrs, SPid),
      M = if SslOpts -> ssl; true -> Mod end,
      monitor(process, MPid),
      MPid ! {start, self(), Sock, M}, %% prepare monitor for sending
      putr(?REF_KEY, Ref),
      setopts(#transport{parent = Pid,
                         module = M,
                         socket = Sock,
                         ssl = SslOpts,
                         timeout = Tmo,
                         monitor = MPid});
  %% Put the reference in the process dictionary since we now use it
  %% advertise the ssl socket after TLS upgrade.
  
  