anchor.diff:              ok;
          true ->
               ct:fail("Send and Recv size not equal: ~p ~p", [SendSize, RecvSize])
  +    end.
  +
  +
  +anc_await_closed_and_down(S, Pid, MRef) ->
  +    anc_await_closed_and_down(S, Pid, MRef, 0, false, false).
  +
  +anc_await_closed_and_down(_S, _Pid, _MRef, Size, true, true) ->
  +    Size;
  +anc_await_closed_and_down(S, Pid, MRef, Size, Closed, Down) ->
  +    receive
  +        {tcp, S, Bin} ->
  +            %% ?P("got a chunk (~w) of data", [byte_size(Bin)]),
  +            anc_await_closed_and_down(S, Pid, MRef,
  +                                      byte_size(Bin) + Size, Closed, Down);
  +        {tcp_closed, S} ->
  +            ?P("got closed -> we are done: ~w", [Size]),
  +            anc_await_closed_and_down(S, Pid, MRef, Size, true, Down);
  +        {tcp_passive, S} ->
  +            %% ?P("got passive -> active"),
  +            inet:setopts(S, [{active, 10}]),
  +            anc_await_closed_and_down(S, Pid, MRef, Size, Closed, true);
  +        {'DOWN', MRef, process, Pid, ok} ->
  +            ?P("Received expected down message regarding client"),
  +            anc_await_closed_and_down(S, Pid, MRef, Size, Closed, true);
  +
  +        {'DOWN', MRef, process, Pid, Reason} ->
  +            ?P("Received UNEXPECTED down message regarding client:"
  +               "~n   Reason:    ~p"
  +               "~n   Port Info: ~p",
  +               [Reason, (catch erlang:port_info(S))]),
  +            ct:fail({unexpected_client_down, Reason}); 
  +
  +       Msg ->
  +            ?P("ignore: ~p", [Msg]),
  +            anc_await_closed_and_down(S, Pid, MRef, Size, Closed, Down)
       end.
   
   %% Test the send_timeout socket option.
  
positive.code:     {ok, S} = gen_tcp:accept(L),
      inet:setopts(S, [{active, 10}]),
      ?P("start collecting data"),
      RecvSize =
          (fun Server(Size) ->
                   receive
                       {tcp, S, Bin} ->
                           %% ?P("got a chunk (~w) of data", [byte_size(Bin)]),
                           Server(byte_size(Bin) + Size);
                       {tcp_closed, S} ->
                           ?P("got closed -> we are done: ~w", [Size]),
                           Size;
                       {tcp_passive, S} ->
                           %% ?P("got passive -> active"),
                           inet:setopts(S, [{active, 10}]),
                           Server(Size);
                       Msg ->
                           ?P("ignore: ~p", [Msg]),
                           Server(Size)
                   end
           end)(0),
  
      ?P("await client process termination"),
      receive
          {'DOWN', MRef, process, Pid, ok} ->
              ok;
          {'DOWN', MRef, process, Pid, CloseRes} ->
              exit({unexpected, close, CloseRes})
      end,
  
      ?P("close listen socket"),
      gen_tcp:close(L),
  
negative.code: 
  %% Check that active n and tcp_close messages behave as expected.
  active_n_closed(Config) when is_list(Config) ->
      ?TC_TRY(active_n_closed, fun() -> do_active_n_closed(Config) end).
  
  do_active_n_closed(_Config) ->
      ?P("create listen socket"),
  