anchor.diff:  %%--------------------------------------------------------------------
   %%% Internal functions
   %%--------------------------------------------------------------------
  -handle_daemon_args(Host, UserOptions0) ->
  -    case Host of
  -        socket ->
  -            {Host, UserOptions0};
  -        any ->
  -            {ok, Host0} = inet:gethostname(),
  -            Inet = proplists:get_value(inet, UserOptions0, inet),
  -            {Host0, [Inet | UserOptions0]};
  -        {_,_,_,_} ->
  -            {Host, [inet, {ip,Host} | UserOptions0]};
  -        {_,_,_,_,_,_,_,_} ->
  -            {Host, [inet6, {ip,Host} | UserOptions0]};
  -        _ ->
  -            error(badarg)
  -    end.
  +handle_daemon_args(HostAddr, Opts) ->
  +    IP = proplists:get_value(ip, Opts),
  +    IPh = case inet:parse_strict_address(HostAddr) of
  +              {ok, IPtuple}   -> IPtuple;
  +              {error, einval} when is_tuple(HostAddr),
  +                                   size(HostAddr)==4 ; size(HostAddr)==6 -> HostAddr;
  +              _ -> undefined
  +          end,
  +    handle_daemon_args(HostAddr, IPh, IP, Opts).
  +
  +
  +%% HostAddr is 'any'
  +handle_daemon_args(any, undefined, undefined, Opts) -> {any, Opts};
  +handle_daemon_args(any, undefined, IP,        Opts) -> {IP,  Opts};
  +
  +%% HostAddr is 'loopback' or "localhost" 
  +handle_daemon_args(loopback, undefined, {127,_,_,_}=IP,       Opts) -> {IP,  Opts};
  +handle_daemon_args(loopback, undefined, {0,0,0,0,0,0,0,1}=IP, Opts) -> {IP,  Opts};
  +handle_daemon_args(loopback, undefined, undefined,            Opts) -> 
  +    IP = case proplists:get_value(inet,Opts) of
  +             true -> {127,0,0,1};
  +             inet -> {127,0,0,1};
  +             inet6 -> {0,0,0,0,0,0,0,1};
  +             _ -> case proplists:get_value(inet6,Opts) of
  +                      true -> {0,0,0,0,0,0,0,1};
  +                      _ -> {127,0,0,1} % default if no 'inet' nor 'inet6'
  +                      end
  +         end,
  +    {IP, [{ip,IP}|Opts]};
  +handle_daemon_args("localhost", IPh, IP, Opts) ->
  +    handle_daemon_args(loopback, IPh, IP, Opts);
  +
  +%% HostAddr is ip and no ip-option
  +handle_daemon_args(_, IP, undefined, Opts) when is_tuple(IP) -> {IP, [{ip,IP}|Opts]};
  +
  +%% HostAddr and ip-option are equal
  +handle_daemon_args(_, IP, IP, Opts) when is_tuple(IP) -> {IP, Opts};
  +
  +%% HostAddr is ip, but ip-option is different!
  +handle_daemon_args(_, IPh, IPo, _) when is_tuple(IPh), is_tuple(IPo) -> error({eoption,{ip,IPo}});
  +
  +%% Something else. Whatever it is, it is wrong.
  +handle_daemon_args(_, _, _, _) -> error(badarg).
   
   %%%----------------------------------------------------------------
   valid_socket_to_use(Socket, {tcp,_,_}) ->
  
positive.code:     daemon(Port, []).
  
  
  daemon(Port, UserOptions) when is_integer(Port), Port >= 0 ->
      daemon(any, Port, UserOptions);
  
  daemon(Socket, UserOptions) when is_port(Socket) ->
      daemon(socket, Socket, UserOptions).
  
  
  daemon(Host0, Port, UserOptions0) ->
      {Host, UserOptions} = handle_daemon_args(Host0, UserOptions0),
      start_daemon(Host, Port, ssh_options:handle_options(server, UserOptions)).
  
  %%--------------------------------------------------------------------
  -spec daemon_info(daemon_ref()) -> ok_error( [{atom(), term()}] ).
  
negative.code:     end.
  
  %%%----------------------------------------------------------------
  fmt_host(any) -> any;
  fmt_host(IP)  when is_tuple(IP) ->  inet:ntoa(IP);
  fmt_host(Str) when is_list(Str) -> Str.
  