- sprintf(buf, "%u", port);
-
- addr = double_addr_lookup(buf);
- ok1(addr);
- fd = net_connect(addr);
- ok1(fd >= 0);
-
- slen = sizeof(saddr);
- ok1(getsockname(fd, &saddr, &slen) == 0);
- diag("family = %d", saddr.sa_family);
- ok1(saddr.sa_family == AF_INET);
- status = read(fd, buf, sizeof(buf));
- ok(status == strlen("Yay!"),
- "Read returned %i (%s)", status, strerror(errno));
- ok1(strncmp(buf, "Yay!", strlen("Yay!")) == 0);
- close(fd);
- double_addr_free(addr);
+ if (port == -1) {
+ /* No IPv4 support? Maybe one day this will happen! */
+ if (errno == EAFNOSUPPORT)
+ skip(6, "No IPv4 socket support");
+ else
+ fail("Could not create IPv4 listening socket: %s",
+ strerror(errno));
+ } else {
+ sprintf(buf, "%u", port);
+
+ addr = double_addr_lookup(buf, &fake_double);
+ ok1(addr);
+ fd = net_connect(addr);
+ ok1(fd >= 0);
+
+ slen = sizeof(saddr);
+ ok1(getsockname(fd, &saddr, &slen) == 0);
+ diag("family = %d", saddr.sa_family);
+ ok1(saddr.sa_family == AF_INET);
+ status = read(fd, buf, sizeof(buf));
+ ok(status == strlen("Yay!"),
+ "Read returned %i (%s)", status, strerror(errno));
+ ok1(strncmp(buf, "Yay!", strlen("Yay!")) == 0);
+ close(fd);
+ double_addr_free(addr, fake_double);
+ }