[ox/logconn] MSVC fixes

This commit is contained in:
Gary Talent 2023-11-11 21:57:25 -06:00
parent 59c11e5309
commit 3fbb2a0086
4 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,6 @@
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(OX_OS_WINDOWS TRUE)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(OX_OS_FREEBSD TRUE)
else()

View File

@ -21,6 +21,7 @@ target_link_libraries(
OxStd
OxMetalClaw
$<$<BOOL:${OX_OS_FREEBSD}>:pthread>
$<$<BOOL:${OX_OS_WINDOWS}>:ws2_32>
)
install(

View File

@ -9,22 +9,36 @@
#ifdef OX_USE_STDLIB
#include <cstdio>
#include <sys/types.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#else
#include <winsock.h>
#undef interface
#undef min
#undef max
#endif
#include <sys/types.h>
#include <ox/std/bit.hpp>
#include "logconn.hpp"
#include <ox/std/bit.hpp>
namespace ox {
using namespace trace;
void closeSock(auto s) noexcept {
#ifdef _WIN32
closesocket(s);
#else
close(s);
#endif
}
LoggerConn::LoggerConn() noexcept: m_netThread([this]{this->msgSend();}) {
}
@ -33,7 +47,7 @@ LoggerConn::~LoggerConn() noexcept {
m_waitCond.notify_one();
m_netThread.join();
if (m_socket) {
close(m_socket);
closeSock(m_socket);
}
}