@@ -230,23 +230,17 @@ static int make_server(int sotype, const char *ip, int port,
static int make_client(int sotype, const char *ip, int port)
{
+ int family = is_ipv6(ip) ? AF_INET6 : AF_INET;
+ struct network_helper_opts opts = {
+ .timeout_ms = IO_TIMEOUT_SEC,
+ };
struct sockaddr_storage addr = {0};
- int err, fd;
+ socklen_t len;
- fd = make_socket(sotype, ip, port, &addr);
- if (fd < 0)
+ if (make_sockaddr(family, ip, port, &addr, &len))
return -1;
- err = connect(fd, (void *)&addr, inetaddr_len(&addr));
- if (CHECK(err, "make_client", "connect")) {
- log_err("failed to connect client socket");
- goto fail;
- }
-
- return fd;
-fail:
- close(fd);
- return -1;
+ return connect_to_addr(sotype, &addr, len, &opts);
}
static __u64 socket_cookie(int fd)