39#include "blocxx/BLOCXX_config.h"
52#if !defined(BLOCXX_WIN32)
55#include <sys/socket.h>
57#include <netinet/in.h>
63#define INVALID_SOCKET -1
120#if defined(BLOCXX_WIN32)
129#if defined(BLOCXX_WIN32)
151#if defined(BLOCXX_WIN32)
162#ifdef BLOCXX_HAVE_IPV6
189 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
196 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
212#ifdef BLOCXX_HAVE_IPV6
242 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
248 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
255#ifdef BLOCXX_HAVE_IPV6
282 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl:: doListen(): getaddrinfo() %1",
292 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
298 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
320 Format(
"WSAEventSelect failed in waitForAcceptIO: %1",
353 BLOCXX_THROW(SocketException,
"ServerSocketImpl::accept: NONE");
360 Format(
"WSAEventSelect failed in accept: %1",
383 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
397 BLOCXX_THROW(SocketException,
"Error while waiting for network events");
399 BLOCXX_THROW(SocketException,
"Shutdown event was signaled");
401 BLOCXX_THROW(SocketTimeoutException,
"Timed out waiting for a connection");
409 Format(
"WSAEventSelect failed in accept: %1",
417 BLOCXX_THROW(SocketException, Format(
"ServerSocketImpl: %1",
439#ifdef BLOCXX_HAVE_IPV6
482 "close-on-exec flag on listen socket");
499#if defined(BLOCXX_NCR)
510#ifdef BLOCXX_HAVE_IPV6
551#ifdef BLOCXX_HAVE_IPV6
615 "close-on-exec flag on listen socket");
628#if defined(BLOCXX_NCR)
639 Format(
"ServerSocketImpl::doListen(): Unable to open or create Unix Domain Socket lock: %1",
646 Format(
"ServerSocketImpl::doListen(): Unable to lock Unix Domain Socket: %1",
656 Format(
"ServerSocketImpl::doListen(): Unable to unlink Unix Domain Socket: %1",
661#if defined(BLOCXX_NCR)
737 "between select() and accept()");
781#if defined(BLOCXX_WIN32)
792 Format(
"ServerSocketImpl::close(): Unable to unlink Unix Domain Socket: %1",
801 Format(
"ServerSocketImpl::close(): Failed to unlock Unix Domain Socket: %1",
808 Format(
"ServerSocketImpl::close(): Unable to unlink Unix Domain Socket lock: %1",
836#if !defined(BLOCXX_WIN32)
#define BLOCXX_ASSERT(CON)
BLOCXX_ASSERT works similar to the assert() macro, but instead of calling abort(),...
#define BLOCXX_THROW(exType, msg)
Throw an exception using FILE and LINE.
#define BLOCXX_THROW_ERRNO_MSG(exType, msg)
Throw an exception using FILE, LINE, errno and strerror(errno)
int unlock()
Release a lock on the file.
int tryLock(ELockType type=E_WRITE_LOCK)
Acquire a kernel lock on the file.
int close()
Close the underlying file object.
void doListenIPv4(UInt16 port, int queueSize, const String &listenAddr)
void doListen(UInt16 port, SocketFlags::ESSLFlag isSSL, int queueSize=10, const String &listenAddr=SocketAddress::ALL_LOCAL_ADDRESSES, SocketFlags::EReuseAddrFlag reuseAddr=SocketFlags::E_REUSE_ADDR)
SocketAddress m_localAddress
SocketFlags::ESSLFlag m_isSSL
Socket accept(const Timeout &timeout)
void doListenUDS(const String &filename, int queueSize=10, bool reuseAddr=true)
Select_t getSelectObj() const
ServerSocketImpl(SSLServerCtxRef sslCtx)
void assignFromNativeForm(const UnixSocketAddress_t *address, size_t len)
AddressType getType() const
size_t getNativeFormSize() const
const SocketAddress_t * getNativeForm() const
static SocketAddress allocEmptyAddress(AddressType type)
Allocate an empty SocketAddress.
static const char *const ALL_LOCAL_ADDRESSES
static SocketAddress getByName(const String &host, unsigned short port=0)
Do a DNS lookup on a hostname and return an SocketAddress for that host.
const String toString() const
Returns the IP address and the port with a colon in between.
static SocketAddress getUDS(const String &filename)
This String class is an abstract data type that represents as NULL terminated string of characters.
const char * c_str() const
static void testCancel()
Test if this thread has been cancelled.
A timeout can be absolute, which means that it will happen at the specified DateTime.
BLOCXX_COMMON_API bool exists(const String &path)
BLOCXX_COMMON_API bool removeFile(const String &path)
Remove the given file.
BLOCXX_COMMON_API File openOrCreateFile(const String &path)
Opens or creates the file for the given name.
int waitForIO(SocketHandle_t fd, int timeOutSecs, SocketFlags::EWaitDirectionFlag waitFlag)
Wait for input or output on a socket.
String lastErrorMsg(bool socketError)
sockaddr_in InetSocketAddress_t
bool operator==(const Array< T > &x, const Array< T > &y)