Low-level OS socket handle.
More...
#include <Socket.h>
|
| Result | create (SocketFlags::AddressFamily addressFamily, SocketFlags::SocketType socketType=SocketFlags::SocketStream, SocketFlags::ProtocolType protocol=SocketFlags::ProtocolTcp, SocketFlags::BlockingType blocking=SocketFlags::Blocking, SocketFlags::InheritableType inheritable=SocketFlags::NonInheritable) |
| | Creates a new SocketDescriptor Descriptor of given family, type, protocol.
|
| |
| Result | isInheritable (bool &value) const |
| | Check if socket is inheritable by child processes.
|
| |
| Result | setInheritable (bool value) |
| | Changes the inheritable flag for this socket.
|
| |
| Result | setBlocking (bool value) |
| | Changes the blocking flag for this socket (if IO reads / writes should be blocking or not)
|
| |
| Result | getAddressFamily (SocketFlags::AddressFamily &addressFamily) const |
| | Get address family (IPV4 / IPV6) of this socket.
|
| |
| Result | shutdown (SocketFlags::ShutdownType shutdownType) |
| | Shuts down the socket for reading, writing, or both.
|
| |
| Result | setTcpNoDelay (bool tcpNoDelay) |
| | Disables Nagle's algorithm for low-latency communication.
|
| |
| Result | setBroadcast (bool enableBroadcast) |
| | Enables or disables broadcast on this socket (for UDP)
|
| |
| Result | joinMulticastGroup (const SocketIPAddress &multicastAddress, const SocketIPAddress &interfaceAddress) |
| | Joins an IPv4 or IPv6 multicast group on a specific interface.
|
| |
| Result | leaveMulticastGroup (const SocketIPAddress &multicastAddress, const SocketIPAddress &interfaceAddress) |
| | Leaves a previously joined IPv4 or IPv6 multicast group on a specific interface.
|
| |
| Result | setMulticastLoopback (SocketFlags::AddressFamily addressFamily, bool enableLoopback) |
| | Controls whether multicast traffic is sent back to the local host.
|
| |
| Result | setMulticastHops (SocketFlags::AddressFamily addressFamily, int hops) |
| | Specifies the default TTL or hop limit for outgoing multicast datagrams.
|
| |
| Result | setMulticastOutboundInterface (const SocketIPAddress &interfaceAddress) |
| | Specifies the default local network interface for outgoing multicast datagrams.
|
| |
Low-level OS socket handle.
It also allow querying inheritability and changing it (and blocking mode)
Example (extracted from unit test):
bool isInheritable;
SC_TEST_EXPECT(socket.
create(SocketFlags::AddressFamilyIPV4, SocketFlags::SocketStream, SocketFlags::ProtocolTcp,
SocketFlags::NonBlocking, SocketFlags::NonInheritable));
isInheritable = false;
SC_TEST_EXPECT(socket.
create(SocketFlags::AddressFamilyIPV4, SocketFlags::SocketStream, SocketFlags::ProtocolTcp,
SocketFlags::Blocking, SocketFlags::NonInheritable));
isInheritable = false;
SC_TEST_EXPECT(socket.
create(SocketFlags::AddressFamilyIPV4, SocketFlags::SocketStream, SocketFlags::ProtocolTcp,
SocketFlags::Blocking, SocketFlags::Inheritable));
isInheritable = false;
◆ create()
Creates a new SocketDescriptor Descriptor of given family, type, protocol.
- Parameters
-
| addressFamily | Address family (IPV4 / IPV6) |
| socketType | SocketDescriptor type (Stream or Dgram) |
| protocol | Protocol (TCP or UDP) |
| blocking | If the socket should be created in blocking mode |
| inheritable | If the socket should be inheritable by child processes |
- Returns
- Valid Result if a socket with the requested options has been successfully created
◆ getAddressFamily()
Get address family (IPV4 / IPV6) of this socket.
- Parameters
-
| [out] | addressFamily | The address family of this socket (if Result is valid) |
- Returns
- Valid Result the address family for this socket has been queried successfully
◆ isInheritable()
| Result SC::SocketDescriptor::isInheritable |
( |
bool & | value | ) |
const |
Check if socket is inheritable by child processes.
- Parameters
-
| [out] | value | if set to true indicates that this socket is inheritable by child processes |
- Returns
- Valid Result if the inheritable status for this socket has been queried successfully
◆ joinMulticastGroup()
Joins an IPv4 or IPv6 multicast group on a specific interface.
- Parameters
-
| multicastAddress | The multicast group address to join |
| interfaceAddress | The local interface address to join on |
- Returns
- Valid Result if the socket has successfully joined the multicast group
◆ leaveMulticastGroup()
Leaves a previously joined IPv4 or IPv6 multicast group on a specific interface.
- Parameters
-
| multicastAddress | The multicast group address to leave |
| interfaceAddress | The local interface address to leave from |
- Returns
- Valid Result if the socket has successfully left the multicast group
◆ setBlocking()
| Result SC::SocketDescriptor::setBlocking |
( |
bool | value | ) |
|
Changes the blocking flag for this socket (if IO reads / writes should be blocking or not)
- Parameters
-
| value | true if this socket should be made blocking, false for non-blocking |
- Returns
- Valid Result if it has been possible changing the blocking status of this socket
◆ setBroadcast()
| Result SC::SocketDescriptor::setBroadcast |
( |
bool | enableBroadcast | ) |
|
Enables or disables broadcast on this socket (for UDP)
- Parameters
-
| enableBroadcast | true to enable broadcast (set SO_BROADCAST), false to disable |
- Returns
- Valid Result if the SO_BROADCAST option has been set successfully
◆ setInheritable()
| Result SC::SocketDescriptor::setInheritable |
( |
bool | value | ) |
|
Changes the inheritable flag for this socket.
- Parameters
-
| value | true if this socket should be made inheritable, false for non-inheritable |
- Returns
- Valid Result if it has been possible changing the inheritable status of this socket
◆ setMulticastHops()
Specifies the default TTL or hop limit for outgoing multicast datagrams.
- Parameters
-
| addressFamily | Address family of the socket |
| hops | The hop limit (0-255) |
- Returns
- Valid Result if the multicast hop limit has been set successfully
◆ setMulticastLoopback()
Controls whether multicast traffic is sent back to the local host.
- Parameters
-
| addressFamily | Address family of the socket |
| enableLoopback | true to enable multicast loopback, false to disable |
- Returns
- Valid Result if the multicast loopback option has been set successfully
◆ setMulticastOutboundInterface()
Specifies the default local network interface for outgoing multicast datagrams.
- Parameters
-
| interfaceAddress | The local interface address |
- Returns
- Valid Result if the multicast outgoing interface has been set successfully
◆ setTcpNoDelay()
| Result SC::SocketDescriptor::setTcpNoDelay |
( |
bool | tcpNoDelay | ) |
|
Disables Nagle's algorithm for low-latency communication.
- Parameters
-
| tcpNoDelay | true to disable Nagle's algorithm (set TCP_NODELAY), false to enable it |
- Returns
- Valid Result if the TCP_NODELAY option has been set successfully
◆ shutdown()
Shuts down the socket for reading, writing, or both.
- Parameters
-
| shutdownType | The type of shutdown to perform |
- Returns
- Valid Result if the socket has been successfully shut down
The documentation for this struct was generated from the following file: