diff options
-rw-r--r-- | include/socket.h | 6 | ||||
-rw-r--r-- | src/inspsocket.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/socket.h b/include/socket.h index c7b87d583..ddd453ac3 100644 --- a/include/socket.h +++ b/include/socket.h @@ -143,6 +143,12 @@ namespace irc */ CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM); + /** Return the size of the structure for syscall passing */ + int sa_size(irc::sockets::sockaddrs& sa) + { + return sa.sa.sa_family == AF_INET ? sizeof(sa.in4) : sizeof(sa.in6); + } + /** Convert an address-port pair into a binary sockaddr * @param addr The IP address, IPv4 or IPv6 * @param port The port, 0 for unspecified diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 41bce84a7..7718fe70a 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -238,7 +238,7 @@ bool BufferedSocket::DoConnect(unsigned long maxtime) ServerInstance->SE->NonBlocking(this->fd); - if (ServerInstance->SE->Connect(this, &addr.sa, sizeof(addr)) == -1) + if (ServerInstance->SE->Connect(this, &addr.sa, sa_size(addr)) == -1) { if (errno != EINPROGRESS) { |