+ int fd;
+
+ if ((fd = socket(addr->ai_family, SOCK_DGRAM, 0)) == -1) {
+ perror("socket()");
+ return false;
+ }
+
+ /* Since the socket was created with SOCK_DGRAM, this is
+ * actually not establishing a connection or generating
+ * any other network traffic. Instead, as a side-effect,
+ * it saves the local address with which packets would
+ * be sent to the destination. */
+ if (connect(fd, addr->ai_addr, addr->ai_addrlen) == -1) {
+ /* We don’t display the error here because most
+ * likely, there just is no IPv6 connectivity.
+ * Thus, don’t spam the user’s console but just
+ * try the next address. */
+ (void)close(fd);
+ return false;
+ }
+