summaryrefslogtreecommitdiff
path: root/zen/socket.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-04-05 11:02:07 -0400
committerB Stack <bgstack15@gmail.com>2021-04-05 11:02:07 -0400
commit74361d859354e4416285cd803b1b0075be1fe514 (patch)
treedafb5e266c513a5ed9863401e62d246742861e0c /zen/socket.h
parentMerge branch '11.7' into 'master' (diff)
downloadFreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.tar.gz
FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.tar.bz2
FreeFileSync-74361d859354e4416285cd803b1b0075be1fe514.zip
add upstream 11.9
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