351 void setOption(
int level,
int optName,
int value);
423 void setOption(
int level,
int optName,
const void* value, socklen_t len);
502 [[nodiscard]]
int getOption(
int level,
int optName)
const;
581 void getOption(
int level,
int optName,
void* result, socklen_t* len)
const;
948 [[nodiscard]] std::pair<bool, int>
getSoLinger()
const;
1539#if defined(IPV6_V6ONLY)
1654#if defined(SO_REUSEPORT)
SOCKET _sockFd
Underlying socket file descriptor.
Definition SocketOptions.hpp:2488
Common platform and utility includes for jsocketpp.
void setMulticastInterfaceIPv4(in_addr addr)
Select the outgoing IPv4 interface for multicast.
Definition SocketOptions.cpp:446
bool getReusePort() const
Checks whether the SO_REUSEPORT option is currently enabled on the socket.
Definition SocketOptions.cpp:333
bool getTcpNoDelay() const
Queries whether Nagle's algorithm (TCP_NODELAY) is currently disabled.
Definition SocketOptions.cpp:269
void setReusePort(const bool enable)
Enables or disables the SO_REUSEPORT socket option.
Definition SocketOptions.cpp:328
static bool is_ipv6_multicast(const in6_addr &v6)
Test whether an IPv6 address is in the multicast range (ff00::/8).
Definition SocketOptions.hpp:2430
static bool is_ipv4_multicast(const in_addr v4)
Test whether an IPv4 address is in the multicast range (224.0.0.0/4).
Definition SocketOptions.hpp:2370
bool getKeepAlive() const
Checks whether TCP-level keepalive (SO_KEEPALIVE) is currently enabled.
Definition SocketOptions.cpp:155
void setMulticastLoopback(bool enable)
Enable or disable multicast loopback for this socket.
Definition SocketOptions.cpp:425
void setMulticastTTL(int ttl)
Set the default multicast hop limit / TTL for this socket.
Definition SocketOptions.cpp:394
std::pair< bool, int > getSoLinger() const
Retrieves the current SO_LINGER configuration of the socket.
Definition SocketOptions.cpp:140
void setOption(int level, int optName, int value)
Sets a low-level socket option on the underlying socket.
Definition SocketOptions.cpp:10
int getSoSendTimeout() const
Retrieves the socket send timeout (SO_SNDTIMEO) in milliseconds.
Definition SocketOptions.cpp:208
bool getIPv6Only() const
Queries whether the IPV6_V6ONLY option is enabled on this socket.
Definition SocketOptions.cpp:305
SocketOptions(SocketOptions &&) noexcept=default
Move constructor for SocketOptions.
void joinGroupIPv6(in6_addr group, unsigned int ifindex)
Join an IPv6 any-source multicast (ASM) group on a specific interface index.
Definition SocketOptions.cpp:500
int getReceiveBufferSize() const
Retrieves the current receive buffer size (SO_RCVBUF) of the socket.
Definition SocketOptions.cpp:112
void leaveGroupIPv4(in_addr group, in_addr iface)
Leave a previously joined IPv4 multicast group on a specific interface.
Definition SocketOptions.cpp:487
int getMulticastTTL() const
Get the socket’s default multicast hop limit / TTL.
Definition SocketOptions.cpp:415
bool getNonBlocking() const
Queries whether the socket is currently in non-blocking mode.
Definition SocketOptions.cpp:246
void setSoRecvTimeout(int millis)
Sets the socket receive timeout (SO_RCVTIMEO) in milliseconds.
Definition SocketOptions.cpp:160
void setNonBlocking(bool nonBlocking)
Enables or disables non-blocking mode on the socket.
Definition SocketOptions.cpp:223
SocketOptions(const SocketOptions &)=delete
Copy constructor (deleted) for SocketOptions.
void joinGroupIPv4(in_addr group, in_addr iface)
Join an IPv4 any-source multicast (ASM) group on a specific interface.
Definition SocketOptions.cpp:470
bool getMulticastLoopback() const
Read the socket’s multicast loopback flag.
Definition SocketOptions.cpp:437
void setReceiveBufferSize(std::size_t size)
Sets the socket's receive buffer size (SO_RCVBUF).
Definition SocketOptions.cpp:107
int getOption(int level, int optName) const
Retrieves the current value of a low-level socket option.
Definition SocketOptions.cpp:43
void setSoLinger(bool enable, int seconds)
Configures the socket's linger behavior (SO_LINGER) during close.
Definition SocketOptions.cpp:128
void setSoSendTimeout(int millis)
Sets the socket send timeout (SO_SNDTIMEO) in milliseconds.
Definition SocketOptions.cpp:178
virtual ~SocketOptions()=default
Virtual destructor for safe polymorphic destruction.
static int detectFamily(SOCKET fd)
Determine the address family (AF_INET or AF_INET6) of a socket.
Definition SocketOptions.cpp:340
void setSendBufferSize(std::size_t size)
Sets the socket's send buffer size (SO_SNDBUF).
Definition SocketOptions.cpp:117
bool getReuseAddress() const
Queries whether the socket is currently configured to allow address reuse.
Definition SocketOptions.cpp:93
void setSocketFd(const SOCKET sock) noexcept
Updates the socket descriptor used by this object.
Definition SocketOptions.hpp:2281
void setTcpNoDelay(bool on)
Enables or disables Nagle’s algorithm (TCP_NODELAY) on TCP sockets.
Definition SocketOptions.cpp:264
void leaveGroupIPv6(in6_addr group, unsigned int ifindex)
Leave a previously joined IPv6 multicast group on a specific interface index.
Definition SocketOptions.cpp:518
SocketOptions()=delete
Default constructor (deleted) for SocketOptions base class.
virtual bool isPassiveSocket() const noexcept
Indicates whether the socket behaves as a passive (listening) socket.
Definition SocketOptions.hpp:2309
int getSoRecvTimeout() const
Retrieves the socket receive timeout (SO_RCVTIMEO) in milliseconds.
Definition SocketOptions.cpp:194
bool getBroadcast() const
Checks whether the socket is currently allowed to send broadcast messages.
Definition SocketOptions.cpp:279
void setReuseAddress(bool on)
Enables or disables the SO_REUSEADDR socket option.
Definition SocketOptions.cpp:74
void setKeepAlive(bool on)
Enables or disables TCP-level keepalive behavior on the socket (SO_KEEPALIVE).
Definition SocketOptions.cpp:150
SocketOptions(const SOCKET sock) noexcept
Initializes the socket option interface with a specific socket descriptor.
Definition SocketOptions.hpp:98
void setIPv6Only(bool enable)
Enables or disables IPV6_V6ONLY mode for IPv6-capable sockets.
Definition SocketOptions.cpp:286
void setBroadcast(bool on)
Enables or disables the ability to send UDP broadcast messages.
Definition SocketOptions.cpp:274
SOCKET getSocketFd() const noexcept
Retrieves the native socket handle (file descriptor or OS-level handle).
Definition SocketOptions.hpp:275
void setMulticastInterfaceIPv6(unsigned int ifindex)
Select the outgoing IPv6 interface for multicast.
Definition SocketOptions.cpp:458
int getSendBufferSize() const
Retrieves the current send buffer size (SO_SNDBUF) of the socket.
Definition SocketOptions.cpp:122
A C++ socket library providing Java-style networking interfaces.
Definition BufferView.hpp:16
constexpr SOCKET INVALID_SOCKET
Definition common.hpp:264
int SOCKET
Definition common.hpp:263