Disable SIGPIPE, should disconnect socket now instead
This commit is contained in:
@@ -163,8 +163,8 @@ namespace fr
|
||||
|
||||
#ifdef _WIN32
|
||||
static WSADATA wsaData;
|
||||
static uint32_t instance_count;
|
||||
#endif // _WIN32
|
||||
static uint32_t instance_count;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -44,7 +44,8 @@ namespace fr
|
||||
{
|
||||
if(error != MBEDTLS_ERR_SSL_WANT_READ && error != MBEDTLS_ERR_SSL_WANT_WRITE)
|
||||
{
|
||||
return Socket::Status::Error;
|
||||
is_connected = false;
|
||||
return Socket::Status::Disconnected;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include <mutex>
|
||||
#include <csignal>
|
||||
#include "frnetlib/NetworkEncoding.h"
|
||||
#include "frnetlib/Socket.h"
|
||||
|
||||
@@ -10,25 +11,28 @@ namespace fr
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WSADATA Socket::wsaData = WSADATA();
|
||||
uint32_t Socket::instance_count = 0;
|
||||
#endif // _WIN32
|
||||
uint32_t Socket::instance_count = 0;
|
||||
|
||||
Socket::Socket() noexcept
|
||||
: is_blocking(true),
|
||||
is_connected(false)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if(instance_count == 0)
|
||||
{
|
||||
//Disable SIGPIPE
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
#ifdef _WIN32
|
||||
int wsa_result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if(wsa_result != 0)
|
||||
{
|
||||
std::cout << "Failed to initialise WSA." << std::endl;
|
||||
return;
|
||||
}
|
||||
#endif // _WIN32
|
||||
}
|
||||
instance_count++;
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
Socket::Status Socket::send(Packet &packet)
|
||||
|
||||
Reference in New Issue
Block a user