Fix incorrect error reported on socket creation

This commit is contained in:
Patrick Nicolas
2025-08-20 22:11:43 +02:00
parent fadec7a7a0
commit bebd2cd97e
+3 -6
View File
@@ -69,10 +69,9 @@ wivrn::fd_base::~fd_base()
wivrn::UDP::UDP() wivrn::UDP::UDP()
{ {
fd = socket(AF_INET6, SOCK_DGRAM, 0); fd = socket(AF_INET6, SOCK_DGRAM, 0);
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (fd < 0) if (fd < 0)
throw std::system_error{errno, std::generic_category()}; throw std::system_error{errno, std::generic_category()};
fcntl(fd, F_SETFD, FD_CLOEXEC);
} }
wivrn::UDP::UDP(int fd) wivrn::UDP::UDP(int fd)
@@ -177,10 +176,9 @@ wivrn::TCP::TCP(int fd)
wivrn::TCP::TCP(in6_addr address, int port) wivrn::TCP::TCP(in6_addr address, int port)
{ {
fd = socket(AF_INET6, SOCK_STREAM, 0); fd = socket(AF_INET6, SOCK_STREAM, 0);
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (fd < 0) if (fd < 0)
throw std::system_error{errno, std::generic_category()}; throw std::system_error{errno, std::generic_category()};
fcntl(fd, F_SETFD, FD_CLOEXEC);
sockaddr_in6 sa; sockaddr_in6 sa;
sa.sin6_family = AF_INET6; sa.sin6_family = AF_INET6;
@@ -199,10 +197,9 @@ wivrn::TCP::TCP(in6_addr address, int port)
wivrn::TCP::TCP(in_addr address, int port) wivrn::TCP::TCP(in_addr address, int port)
{ {
fd = socket(AF_INET, SOCK_STREAM, 0); fd = socket(AF_INET, SOCK_STREAM, 0);
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (fd < 0) if (fd < 0)
throw std::system_error{errno, std::generic_category()}; throw std::system_error{errno, std::generic_category()};
fcntl(fd, F_SETFD, FD_CLOEXEC);
sockaddr_in sa; sockaddr_in sa;
sa.sin_family = AF_INET; sa.sin_family = AF_INET;