if (err)
return translate_ai_error (err);
for (a = addrs; a; a = a->ai_next) {
- /* AIX 4.3.3 is broken. */
+ /* AIX 4.3.3 libc is broken. */
if (a->ai_addr->sa_family == 0)
a->ai_addr->sa_family = a->ai_family;
+#ifdef HAVE_SA_LEN
+ if (a->ai_addr->sa_len == 0)
+ switch (a->ai_addr->sa_family) {
+ case AF_INET:
+ a->ai_addr->sa_len = sizeof (struct sockaddr_in);
+ break;
+#ifdef KRB5_USE_INET6
+ case AF_INET6:
+ a->ai_addr->sa_len = sizeof (struct sockaddr_in6);
+ break;
+#endif
+ default:
+ /* oh well, we lose */
+ break;
+ }
+#endif
set_port_num (a->ai_addr, port);
err = add_addrinfo_to_list (lp, a);
* protocol exists to support a particular socket type
* within a given protocol family.
*/
+#ifdef DEBUG
+ fprintf (stderr, "getting dgram socket in family %d...",
+ addrs.addrs[host]->sa_family);
+#endif
socklist[host] = socket(addrs.addrs[host]->sa_family,
SOCK_DGRAM, 0);
- if (socklist[host] == INVALID_SOCKET)
+ if (socklist[host] == INVALID_SOCKET) {
+#ifdef DEBUG
+ perror ("socket");
+ fprintf (stderr, "af was %d\n", addrs.addrs[host]->sa_family);
+#endif
continue; /* try other hosts */
+ }
+#ifdef DEBUG
+ {
+ char addrbuf[NI_MAXHOST], portbuf[NI_MAXSERV];
+ if (0 != getnameinfo (addrs.addrs[host],
+ socklen (addrs.addrs[host]),
+ addrbuf, sizeof (addrbuf),
+ portbuf, sizeof (portbuf),
+ NI_NUMERICHOST | NI_NUMERICSERV))
+ strcpy (addrbuf, "??"), strcpy (portbuf, "??");
+ fprintf (stderr, " fd %d; connecting to %s port %s...",
+ socklist[host], addrbuf, portbuf);
+ }
+#endif
/* have a socket to send/recv from */
/* On BSD systems, a connected UDP socket will get connection
refused and net unreachable errors while an unconnected
sendto, recvfrom. The connect here may return an error if
the destination host is known to be unreachable. */
if (connect(socklist[host],
- addrs.addrs[host], socklen(addrs.addrs[host])) == SOCKET_ERROR)
- continue;
+ addrs.addrs[host], socklen(addrs.addrs[host])) == SOCKET_ERROR) {
+#ifdef DEBUG
+ perror ("connect");
+#endif
+ continue;
+ }
}
+#ifdef DEBUG
+ fprintf (stderr, "sending...");
+#endif
if (send(socklist[host],
message->data, (int) message->length, 0)
- != message->length)
- continue;
+ != message->length) {
+#ifdef DEBUG
+ perror ("sendto");
+#endif
+ continue;
+ }
+#ifdef DEBUG
+ fprintf (stderr, "\n");
+#endif
retry:
waitlen.tv_usec = 0;
waitlen.tv_sec = timeout;