We need better network address conv helpers.
This is what our applets want:

          sockaddr -> hostname
udhcp:    hostname -> ipv4 addr
nslookup: hostname -> list of names - done
tftp:     host,port -> sockaddr
nc:       host,port -> sockaddr
inetd: ?
traceroute: ?, hostname -> ipv4 addr
arping    hostname -> ipv4 addr
ping6     hostname -> ipv6 addr
ifconfig  hostname -> ipv4 addr (FIXME error check?)
ipcalc    ipv4 addr -> hostname
syslogd   hostname -> sockaddr
inet_common.c: buggy. hostname -> ipv4 addr
mount     hostname -> sockaddr_in

==================
HOWTO get rid of inet_ntoa/aton:

foo.sin_addr.s_addr = inet_addr(cp);
-
inet_pton(AF_INET, cp, &foo.sin_addr);

inet_aton(cp, &foo.sin_addr);
-
inet_pton(AF_INET, cp, &foo.sin_addr);

ptr = inet_ntoa(foo.sin_addr);
-
char str[INET_ADDRSTRLEN];
ptr = inet_ntop(AF_INET, &foo.sin_addr, str, sizeof(str));

===================

       struct addrinfo {
           int     ai_flags;
           int     ai_family;
           int     ai_socktype;
           int     ai_protocol;
           size_t  ai_addrlen;
           struct sockaddr *ai_addr;
           char   *ai_canonname;
           struct addrinfo *ai_next;
       };
       int getaddrinfo(const char *node, const char *service,
                       const struct addrinfo *hints,
                       struct addrinfo **res);

       void freeaddrinfo(struct addrinfo *res);

       const char *gai_strerror(int errcode);

       The members ai_family, ai_socktype, and ai_protocol have the same  meaning
       as  the corresponding parameters in the socket(2) system call.  The getad-
       drinfo(3) function returns socket addresses in either IPv4 or IPv6 address
       family, (ai_family will be set to either AF_INET or AF_INET6).

       The  hints  parameter specifies the preferred socket type, or protocol.  A
       NULL hints specifies that any network address or protocol  is  acceptable.
       If  this  parameter  is  not NULL it points to an addrinfo structure whose
       ai_family, ai_socktype, and  ai_protocol  members  specify  the  preferred
       socket type.  AF_UNSPEC in ai_family specifies any protocol family (either
       IPv4 or IPv6, for example).  0 in  ai_socktype  or  ai_protocol  specifies
       that any socket type or protocol is acceptable as well.  The ai_flags mem-
       ber specifies additional options, defined below.  Multiple flags are spec-
       ified  by  logically  OR-ing  them together.  All the other members in the
       hints parameter must contain either 0, or a null pointer.

       The node or service parameter, but not both, may be NULL.  node  specifies
       either  a  numerical network address (dotted-decimal format for IPv4, hex-
       adecimal format for IPv6) or a network hostname, whose  network  addresses
       are looked up and resolved.  If hints.ai_flags contains the AI_NUMERICHOST
       flag then the node parameter must be a  numerical  network  address.   The
       AI_NUMERICHOST  flag  suppresses  any  potentially  lengthy  network  host
       address lookups.

       The getaddrinfo(3) function creates a linked list of addrinfo  structures,
       one  for  each  network address subject to any restrictions imposed by the
       hints parameter.  The ai_canonname field of the first  of  these  addrinfo
       structures  is  set  to  point  to  the  official  name  of  the  host, if
       hints.ai_flags includes the AI_CANONNAME  flag.   ai_family,  ai_socktype,
       and  ai_protocol specify the socket creation parameters.  A pointer to the
       socket address is placed in the ai_addr member,  and  the  length  of  the
       socket address, in bytes, is placed in the ai_addrlen member.

       If  node is NULL, the network address in each socket structure is initial-
       ized according to the AI_PASSIVE flag, which  is  set  in  hints.ai_flags.
       The  network  address in each socket structure will be left unspecified if
       AI_PASSIVE flag is set.  This is used by server applications, which intend
       to  accept client connections on any network address.  The network address
       will be set to the loopback interface address if the  AI_PASSIVE  flag  is
       not  set.  This is used by client applications, which intend to connect to
       a server running on the same network host.

       If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4 addresses are
       returned  in the list pointed to by result only if the local system has at
       least has at least one IPv4 address configured,  and  IPv6  addresses  are
       only  returned  if  the local system has at least one IPv6 address config-
       ured.

       If hint.ai_flags specifies the AI_V4MAPPED flag, and  hints.ai_family  was
       specified as AF_INET6, and no matching IPv6 addresses could be found, then
       return IPv4-mapped IPv6 addresses in the list pointed to  by  result.   If
       both  AI_V4MAPPED and AI_ALL are specified in hints.ai_family, then return
       both IPv6 and IPv4-mapped IPv6 addresses in the list pointed to by result.
       AI_ALL is ignored if AI_V4MAPPED is not also specified.

       service  sets the port number in the network address of each socket struc-
       ture.  If service is NULL the port number will be left uninitialized.   If
       AI_NUMERICSERV  is  specified  in  hints.ai_flags and service is not NULL,
       then service must point to a string  containing  a  numeric  port  number.
       This  flag  is used to inhibit the invocation of a name resolution service
       in cases where it is known not to be required.


==============

       int getnameinfo(const struct sockaddr *sa, socklen_t salen,
                       char *host, size_t hostlen,
                       char *serv, size_t servlen, int flags);

       The  getnameinfo(3)  function is defined for protocol-independent
       address-to-nodename translation.  It combines the functionality
       of gethostbyaddr(3) and getservbyport(3) and is the inverse of
       getaddrinfo(3).  The sa argument is a pointer to a generic socket address
       structure (of type sockaddr_in or  sockaddr_in6)  of  size  salen  that
       holds  the  input IP address and port number.  The arguments host and
       serv are pointers to buffers (of size hostlen and servlen respectively)
       to hold the return values.

       The caller can specify that no hostname (or no service name) is required
       by providing a NULL host (or serv) argument or a zero hostlen (or servlen)
       parameter. However, at least one of hostname or service name must be requested.

       The flags argument modifies the behaviour of getnameinfo(3) as follows:

       NI_NOFQDN
              If set, return only the hostname part of the FQDN for local hosts.

       NI_NUMERICHOST
              If set, then the numeric form of the hostname is returned.
              (When not set, this will still happen in case the node's name
              cannot be looked up.)

       NI_NAMEREQD
              If set, then a error is returned if the hostname cannot be looked up.

       NI_NUMERICSERV
              If set, then the service address is returned in numeric form,
              for example by its port number.

       NI_DGRAM
              If  set, then the service is datagram (UDP) based rather than stream
              (TCP) based. This is required for the few ports (512-514) that have different
              services for UDP and TCP.

=================

Modified IPv6-aware C code:

    struct addrinfo *res, *aip;
    struct addrinfo hints;
    int sock = -1;
    int error;

    /* Get host address. Any type of address will do. */
    bzero(&hints, sizeof(hints));
    hints.ai_flags = AI_ALL|AI_ADDRCONFIG;
    hints.ai_socktype = SOCK_STREAM;

    error = getaddrinfo(hostname, servicename, &hints, &res);
    if (error != 0) {
       (void) fprintf(stderr,
          "getaddrinfo: %s for host %s service %s\n",
          gai_strerror(error), hostname, servicename);
       return (-1);
    }
    /* Try all returned addresses until one works */
    for (aip = res; aip != NULL; aip = aip->ai_next) {
       /*
       * Open socket. The address type depends on what
       * getaddrinfo() gave us.
       */
       sock = socket(aip->ai_family, aip->ai_socktype, aip->ai_protocol);
       if (sock == -1) {
          perror("socket");
          freeaddrinfo(res);
          return (-1);
       }

       /* Connect to the host. */
       if (connect(sock, aip->ai_addr, aip->ai_addrlen) == -1) {
          perror("connect");
          (void) close(sock);
          sock = -1;
          continue;
       }
       break;
    }
    freeaddrinfo(res);

Note that for new applications, if you write address-family-agnostic data structures,
there is no need for porting.

However, when it comes to server-side programming in C/C++, there is an additional wrinkle.
Namely, depending on whether your application is written for a dual-stack platform, such
as Solaris or Linux, or a single-stack platform, such as Windows, you would need to
structure the code differently.

Here's the corresponding server C code for a dual-stack platform:

    int ServSock, csock;
    struct sockaddr addr, from;
    ...
    ServSock = socket(AF_INET6, SOCK_STREAM, PF_INET6);
    bind(ServSock, &addr, sizeof(addr));
    do {
       csock = accept(ServSocket, &from, sizeof(from));
       doClientStuff(csock);
    } while (!finished);
