fix(Net): Add POCO_HAS_UNIX_SOCKET guards to fix build without Unix sockets #5064

This commit is contained in:
Matej Kenda
2025-12-15 21:39:38 +01:00
parent edd582249d
commit 227f84fb8b
6 changed files with 9 additions and 12 deletions

View File

@@ -54,7 +54,7 @@
#include "Poco/Data/ODBC/Unicode.h"
#if (__cplusplus >= 201703L)
#if POCO_HAVE_CPP17_COMPILER
#if __has_include(<msodbcsql.h>)
#include <msodbcsql.h>
#define POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT

View File

@@ -32,16 +32,6 @@
#endif
//
// Thread-safety of local static initialization
//
#if __cplusplus >= 201103L || __GNUC__ >= 4 || defined(__clang__)
#ifndef POCO_LOCAL_STATIC_INIT_IS_THREADSAFE
#define POCO_LOCAL_STATIC_INIT_IS_THREADSAFE 1
#endif
#endif
//
// No syslog.h on QNX/BB10
//

View File

@@ -18,6 +18,7 @@
#define Net_SocketDefs_INCLUDED
#include "Poco/Config.h"
#include <vector>
@@ -33,7 +34,7 @@
#include <ws2tcpip.h>
#include <ws2def.h>
#if !defined (POCO_NET_NO_UNIX_SOCKET)
#if (__cplusplus >= 201703L)
#if POCO_HAVE_CPP17_COMPILER
#if __has_include(<afunix.h>)
#include <afunix.h>
#define POCO_HAS_UNIX_SOCKET

View File

@@ -196,7 +196,9 @@ void HTTPSession::connect(const SocketAddress& address)
_socket.connect(address, _connectionTimeout);
_socket.setReceiveTimeout(_receiveTimeout);
_socket.setSendTimeout(_sendTimeout);
#if defined(POCO_HAS_UNIX_SOCKET)
if (address.family() != SocketAddress::UNIX_LOCAL)
#endif
_socket.setNoDelay(true);
// There may be leftover data from a previous (failed) request in the buffer,
// so we clear it.

View File

@@ -380,11 +380,13 @@ void SocketAddress::init(const std::string& hostAndPort)
{
poco_assert (!hostAndPort.empty());
#if defined(POCO_HAS_UNIX_SOCKET)
if (isUnixLocal(hostAndPort))
{
newLocal(hostAndPort);
return;
}
#endif
std::string host;
std::string port;

View File

@@ -47,7 +47,9 @@ WebSocketImpl::WebSocketImpl(StreamSocketImpl* pStreamSocketImpl, HTTPSession& s
// for small WebSocket frames. Skip for Unix domain sockets.
try
{
#if defined(POCO_HAS_UNIX_SOCKET)
if (_pStreamSocketImpl->address().family() != SocketAddress::UNIX_LOCAL)
#endif
_pStreamSocketImpl->setNoDelay(true);
}
catch (NetException&)