if (!port) return 0;
text2sockaddr (char *address, char *port, struct sockaddr **sa){#ifdef HAVE_GETNAMEINFO  struct addrinfo *ai, hints;  memset (&hints, 0, sizeof hints);  if (!allow_name_lookups)    hints.ai_flags = AI_NUMERICHOST;  hints.ai_family = PF_UNSPEC;  hints.ai_socktype = SOCK_DGRAM;  hints.ai_protocol = IPPROTO_UDP;  if (getaddrinfo (address, port, &hints, &ai))    return -1;  *sa = malloc (sysdep_sa_len (ai->ai_addr));  if (!sa)    return -1;  memcpy (*sa, ai->ai_addr, sysdep_sa_len (ai->ai_addr));  freeaddrinfo (ai);  return 0;#else  int af = strchr (address, ':') != NULL ? AF_INET6 : AF_INET;  size_t sz = af == AF_INET    ? sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6);  long lport;  struct servent *sp;  char *ep;  *sa = calloc (1, sz);  if (!*sa)    return -1;#ifndef USE_OLD_SOCKADDR  (*sa)->sa_len = sz;#endif  (*sa)->sa_family = af;  if (inet_pton (af, address, sockaddr_addrdata (*sa)) != 1)    {      free (*sa);      return -1;    }  sp = getservbyname (port, "udp");  if (!sp)    {      lport = strtol (port, &ep, 10);      if (ep == port || lport < 0 || lport > USHRT_MAX)	{	  free (*sa);	  return -1;	}      lport = htons (lport);    }  else    lport = sp->s_port;  if ((*sa)->sa_family == AF_INET)    ((struct sockaddr_in *)*sa)->sin_port = lport;  else    ((struct sockaddr_in6 *)*sa)->sin6_port = lport;  return 0;#endif}