 
 HOOK: (datagram) io-backend ( addr -- datagram )
 
-
 TUPLE: raw-port < port addr ;
 
 HOOK: (raw) io-backend ( addr -- raw )

    drop resolve-localhost ;

M: object resolve-localhost
    ipv6-supported? [
        { T{ ipv4 f "0.0.0.0" } T{ ipv6 f "::" } }
    ] [
        { T{ ipv4 f "0.0.0.0" } }
    ] if ;

: host-name ( -- string )
    256 <byte-array> dup dup length gethostname

MEMO: ipv6-supported? ( -- ? )
    [ "::1" 0 <inet6> binary <server> dispose t ] [ drop f ] recover ;

[ \ ipv6-supported? reset-memoized ] "io.sockets" add-startup-hook

GENERIC: resolve-host ( addrspec -- seq )

