anchor.diff:  %% (removed) when the controlling process terminates (without explicitly 
   %% calling the close function). For a IPv6 UDP (dgram) socket.
   
  -socket_cleanup_udp6(suite) ->
  -    [];
  -socket_cleanup_udp6(doc) ->
  -    [];
  -socket_cleanup_udp6(_Config) when is_list(_Config) ->
  -    tc_try(socket_cleanup_udp6,
  +sc_socket_cleanup_udp6(suite) ->
  +    [];
  +sc_socket_cleanup_udp6(doc) ->
  +    [];
  +sc_socket_cleanup_udp6(_Config) when is_list(_Config) ->
  +    tc_try(sc_socket_cleanup_udp6,
              fun() ->
                      not_yet_implemented(),
                      InitState = #{domain   => inet6,
                                    type     => dgram,
                                    protocol => udp},
  -                   ok = socket_cleanup(InitState)
  -           end).
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -
  -socket_cleanup(_InitState) ->
  -    ok.
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -%% This test case is intended to test what happens when a process other 
  -%% than the controlling process closes a socket. 
  -%% For a IPv4 TCP (stream) socket.
  -
  -socket_close_tcp4(suite) ->
  -    [];
  -socket_close_tcp4(doc) ->
  -    [];
  -socket_close_tcp4(_Config) when is_list(_Config) ->
  -    tc_try(socket_close_tcp4,
  -           fun() ->
  -                   not_yet_implemented(),
  -                   InitState = #{domain   => inet,
  -                                 type     => stream,
  -                                 protocol => tcp},
  -                   ok = socket_close(InitState)
  -           end).
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -%% This test case is intended to test what happens when a process other 
  -%% than the controlling process closes a socket. 
  -%% For a IPv6 TCP (stream) socket.
  -
  -socket_close_tcp6(suite) ->
  -    [];
  -socket_close_tcp6(doc) ->
  -    [];
  -socket_close_tcp6(_Config) when is_list(_Config) ->
  -    tc_try(socket_close_tcp6,
  -           fun() ->
  -                   not_yet_implemented(),
  -                   InitState = #{domain   => inet6,
  -                                 type     => stream,
  -                                 protocol => tcp},
  -                   ok = socket_close(InitState)
  -           end).
  -
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -%% This test case is intended to test what happens when a process other 
  -%% than the controlling process closes a socket. 
  -%% For a IPv4 UDP (dgram) socket.
  -
  -socket_close_udp4(suite) ->
  -    [];
  -socket_close_udp4(doc) ->
  -    [];
  -socket_close_udp4(_Config) when is_list(_Config) ->
  -    tc_try(socket_close_udp4,
  -           fun() ->
  -                   not_yet_implemented(),
  -                   InitState = #{domain   => inet,
  -                                 type     => dgram,
  -                                 protocol => udp},
  -                   ok = socket_close(InitState)
  -           end).
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -%% This test case is intended to test what happens when a process other 
  -%% than the controlling process closes a socket. 
  -%% For a IPv6 UDP (dgram) socket.
  -
  -socket_close_udp6(suite) ->
  -    [];
  -socket_close_udp6(doc) ->
  -    [];
  -socket_close_udp6(_Config) when is_list(_Config) ->
  -    tc_try(socket_close_udp6,
  -           fun() ->
  -                   not_yet_implemented(),
  -                   InitState = #{domain   => inet6,
  -                                 type     => dgram,
  -                                 protocol => udp},
  -                   ok = socket_close(InitState)
  -           end).
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -
  -socket_close(_InitState) ->
  -    ok.
  -
  +                   ok = sc_socket_cleanup(InitState)
  +           end).
  +
  +
  +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  +
  +sc_socket_cleanup(InitState) ->
  +    OwnerSeq =
  +        [
  +         %% *** Wait for start order part ***
  +         #{desc => "await start (from tester)",
  +           cmd  => fun(State) ->
  +                           receive
  +                               {start, Tester} when is_pid(Tester) ->
  +                                   {ok, State#{tester => Tester}}
  +                           end
  +                   end},
  +
  +         %% *** Init part ***
  +         #{desc => "monitor tester",
  +           cmd  => fun(#{tester := Tester} = _State) ->
  +                           _MRef = erlang:monitor(process, Tester),
  +                           ok
  +                   end},
  +         #{desc => "create socket",
  +           cmd  => fun(#{domain   := Domain, 
  +                         type     := Type, 
  +                         protocol := Proto} = State) ->
  +                           case socket:open(Domain, Type, Proto) of
  +                               {ok, Sock} ->
  +                                   {ok, State#{sock => Sock}};
  +                               {error, _} = ERROR ->
  +                                   ERROR
  +                           end
  +                   end},
  +         #{desc => "announce ready",
  +           cmd  => fun(#{tester := Tester, sock := Sock} = _State) ->
  +                           Tester ! {ready, self(), Sock},
  +                           ok
  +                   end},
  +
  +         %% *** The actual test ***
  +         %% We intentially leave the socket "as is", no explicit close
  +         #{desc => "await terminate (from tester)",
  +           cmd  => fun(#{tester := Tester} = State) ->
  +                           receive
  +                               {'DOWN', _, process, Tester, Reason} ->
  +                                   ee("Unexpected DOWN regarding tester ~p: "
  +                                      "~n   ~p", [Reason]),
  +                                   {error, {unexpected_exit, tester}};
  +                               {terminate, Tester} ->
  +                                   {ok, maps:remove(tester, State)}
  +                           end
  +                   end},
  +         #{desc => "enable (otp) debug",
  +           cmd  => fun(#{sock := Sock} = _State) ->
  +                           ok = socket:setopt(Sock, otp, debug, true)
  +                   end},
  +
  +         %% *** We are done ***
  +         #{desc => "finish",
  +           cmd  => fun(_) ->
  +                           {ok, normal}
  +                   end}
  +        ],
  +
  +    TesterSeq =
  +        [
  +         %% *** Init part ***
  +         #{desc => "monitor owner",
  +           cmd  => fun(#{owner := Owner} = _State) ->
  +                           _MRef = erlang:monitor(process, Owner),
  +                           ok
  +                   end},
  +         #{desc => "order (owner) start",
  +           cmd  => fun(#{owner := Pid} = _State) ->
  +                           Pid ! {start, self()},
  +                           ok
  +                   end},
  +         #{desc => "await (owner) ready",
  +           cmd  => fun(#{owner := Owner} = State) ->
  +                           receive
  +                               {'DOWN', _, process, Owner, Reason} ->
  +                                   ee("Unexpected DOWN regarding owner ~p: "
  +                                      "~n   ~p", [Reason]),
  +                                   {error, {unexpected_exit, owner}};
  +                               {ready, Owner, Sock} ->
  +                                   {ok, State#{sock => Sock}}
  +                           end
  +                   end},
  +         #{desc => "verify owner as controlling-process",
  +           cmd  => fun(#{owner := Owner, sock := Sock} = _State) ->
  +                           case socket:getopt(Sock, otp, controlling_process) of
  +                               {ok, Owner} ->
  +                                   ok;
  +                               {ok, Other} ->
  +                                   {error, {unexpected_owner, Other}};
  +                               {error, _} = ERROR ->
  +                                   ERROR
  +                           end
  +                   end},
  +         #{desc => "order (owner) terminate",
  +           cmd  => fun(#{owner := Pid} = _State) ->
  +                           Pid ! {terminate, self()},
  +                           ok
  +                   end},
  +         #{desc => "await (owner) termination",
  +           cmd  => fun(#{owner := Owner} = _State) ->
  +                           receive
  +                               {'DOWN', _, process, Owner, _} ->
  +                                   ok
  +                           end
  +                   end},
  +         #{desc => "verify no socket (closed)",
  +           cmd  => fun(#{owner := Owner, sock := Sock} = _State) ->
  +                           case socket:getopt(Sock, otp, controlling_process) of
  +                               {ok, Pid} ->
  +                                   {error, {unexpected_success, Owner, Pid}};
  +                               {error, closed} ->
  +                                   ok;
  +                               {error, Reason} ->
  +                                   ei("expected failure: ~p", [Reason]),
  +                                   {error, {unexpected_failure, Reason}}
  +                           end
  +                   end},
  +
  +         %% *** We are done ***
  +         #{desc => "finish",
  +           cmd  => fun(_) ->
  +                           {ok, normal}
  +                   end}
  +        ],
  +
  +    p("start (socket) owner evaluator"),
  +    Owner = evaluator_start("owner", OwnerSeq, InitState),
  +
  +    p("start tester evaluator"),
  +    TesterInitState = #{owner => Owner},
  +    Tester = evaluator_start("tester", TesterSeq, TesterInitState),
  +
  +    p("await evaluator"),
  +    ok = await_evaluator_finish([Owner, Tester]).
   
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
positive.code: %% locally closed while the process is calling the recv function.
  %% Socket is IPv4.
  
  recv_response_local_close_tcp4(suite) ->
      [];
  recv_response_local_close_tcp4(doc) ->
      [];
  recv_response_local_close_tcp4(_Config) when is_list(_Config) ->
      tc_try(recv_response_local_close_tcp4,
             fun() ->
                     not_yet_implemented(),
                     Recv      = fun(Sock) -> socket:recv(Sock) end,
  
negative.code:                                  type     => stream,
                                   protocol => tcp,
                                   recv     => Recv},
                     ok = sc_receive_response_remote_close_tcp(InitState)
             end).
  
  
  