commit 534d784209a6252c09e07c8868cdaab798727244
parent 45e892828afe6b7a7c3e49046bd380c02497f596
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Mon, 25 Jan 2021 22:07:56 -0800
Allow any address family
There isn't a point to limiting it to IPv4. Also limit the protocol
to TCP as Gopher resides there.
Diffstat:
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net.c b/net.c
@@ -35,8 +35,9 @@ resolve(char const *host, char const *port)
struct addrinfo *ai, *ai0;
memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
+ hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
error = getaddrinfo(host, port, &hints, &ai0);
if (error) {
@@ -55,10 +56,8 @@ resolve(char const *host, char const *port)
}
freeaddrinfo(ai0);
- if (s == -1) {
+ if (s == -1)
warn(errno, "unable to connect '%s' (%s)", host, port);
- return -1;
- }
return s;
}