Low-level OS socket handle.
More...
#include <SocketDescriptor.h>
Low-level OS socket handle.
It also allow querying inheritability and changing it (and blocking mode) Example (extracted from unit test):
SocketDescriptor socket;
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition: Testing.h:113
Result isInheritable(bool &value) const
Check if socket is inheritable by child processes.
@ SocketStream
Sets the socket type as Streaming type (for TCP and others)
Definition: SocketDescriptor.h:92
@ AddressFamilyIPV4
IP Address is IPV4.
Definition: SocketDescriptor.h:85
@ NonInheritable
Socket will not be inherited by child processes.
Definition: SocketDescriptor.h:78
@ Inheritable
Socket will be inherited by child processes.
Definition: SocketDescriptor.h:79
@ NonBlocking
Socket is in non-blocking mode.
Definition: SocketDescriptor.h:71
@ Blocking
Socket is in blocking mode.
Definition: SocketDescriptor.h:72
@ ProtocolTcp
The protocol is TCP.
Definition: SocketDescriptor.h:99
◆ create()
Creates a new Socket Descriptor of given family, type, protocol.
- Parameters
-
addressFamily | Address family (IPV4 / IPV6) |
socketType | Socket 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
◆ 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
◆ 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
The documentation for this struct was generated from the following file: