1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 20:24:26 +01:00

Merge pull request #433 from visuve/master

Close socket when setsockopt fails
This commit is contained in:
Matias Fontanini
2021-03-06 11:34:51 -08:00
committed by GitHub

View File

@@ -267,6 +267,11 @@ void PacketSender::open_l3_socket(SocketType type) {
#endif
const int level = (is_v6) ? IPPROTO_IPV6 : IPPROTO_IP;
if (setsockopt(sockfd, level, IP_HDRINCL, (option_ptr)&on, sizeof(on)) != 0) {
#ifndef _WIN32
::close(sockfd);
#else
::closesocket(sockfd);
#endif
throw socket_open_error(make_error_string());
}