int va_socktype;
int va_protocol;
socklen_t va_addrlen;
- struct sockaddr_storage va_addr;
+ union {
+ struct sockaddr_storage _storage;
+ struct sockaddr sa;
+ } va_addr;
};
/*
val = 1;
if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val) != 0) {
perror("setsockopt(SO_REUSEADDR, 1)");
- close(sd);
+ (void)close(sd);
return (-1);
}
#ifdef IPV6_V6ONLY
if (va->va_family == AF_INET6 &&
setsockopt(sd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val) != 0) {
perror("setsockopt(IPV6_V6ONLY, 1)");
- close(sd);
+ (void)close(sd);
return (-1);
}
#endif
- if (bind(sd, (const struct sockaddr *)&va->va_addr, va->va_addrlen) != 0) {
+ if (bind(sd, &va->va_addr.sa, va->va_addrlen) != 0) {
perror("bind()");
- close(sd);
+ (void)close(sd);
return (-1);
}
if (listen(sd, depth) != 0) {
perror("listen()");
- close(sd);
+ (void)close(sd);
return (-1);
}
return (sd);
perror("socket()");
return (-1);
}
- if (connect(sd, (const struct sockaddr *)&va->va_addr, va->va_addrlen) != 0) {
+ if (connect(sd, &va->va_addr.sa, va->va_addrlen) != 0) {
perror("connect()");
- close(sd);
+ (void)close(sd);
return (-1);
}
return (sd);