summaryrefslogtreecommitdiff
path: root/zen/socket.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-04-05 15:59:11 +0000
committerB. Stack <bgstack15@gmail.com>2021-04-05 15:59:11 +0000
commit8d28254d708c88ae4aaebbc82cbb6c91726aa390 (patch)
treedafb5e266c513a5ed9863401e62d246742861e0c /zen/socket.h
parentMerge branch '11.7' into 'master' (diff)
parentadd upstream 11.9 (diff)
downloadFreeFileSync-8d28254d708c88ae4aaebbc82cbb6c91726aa390.tar.gz
FreeFileSync-8d28254d708c88ae4aaebbc82cbb6c91726aa390.tar.bz2
FreeFileSync-8d28254d708c88ae4aaebbc82cbb6c91726aa390.zip
Merge branch '11.9' into 'master'11.9
add upstream 11.9 See merge request opensource-tracking/FreeFileSync!32
Diffstat (limited to 'zen/socket.h')
-rw-r--r--zen/socket.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/zen/socket.h b/zen/socket.h
index 2dd1ff4c..f9813852 100644
--- a/zen/socket.h
+++ b/zen/socket.h
@@ -14,6 +14,7 @@
#include <netdb.h> //getaddrinfo
+
namespace zen
{
#define THROW_LAST_SYS_ERROR_WSA(functionName) \
@@ -48,11 +49,15 @@ public:
const auto getConnectedSocket = [](const auto& /*::addrinfo*/ ai)
{
- SocketType testSocket = ::socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol);
+ SocketType testSocket = ::socket(ai.ai_family, //int socket_family
+ SOCK_CLOEXEC |
+ ai.ai_socktype, //int socket_type
+ ai.ai_protocol); //int protocol
if (testSocket == invalidSocket)
THROW_LAST_SYS_ERROR_WSA("socket");
ZEN_ON_SCOPE_FAIL(closeSocket(testSocket));
+
if (::connect(testSocket, ai.ai_addr, static_cast<int>(ai.ai_addrlen)) != 0)
THROW_LAST_SYS_ERROR_WSA("connect");
bgstack15