Use a SocketDescriptor as a Server (example TCP or UDP Socket Server). More...
#include <Socket.h>
Public Types | |
| enum class | BindReuseAddress : uint8_t { Disabled , Enabled } |
| enum class | BindStatus : uint8_t { None , AddressInUse } |
Public Member Functions | |
| SocketServer (SocketDescriptor &socket) | |
| Build a SocketServer from a SocketDescriptor (already created with SocketDescriptor::create) | |
| Result | close () |
| Calls SocketDescriptor::close. | |
| Result | bind (const SocketAddress &nativeAddress, BindReuseAddress reuseAddress=BindReuseAddress::Enabled, BindStatus *outStatus=nullptr) |
| Binds this socket to an address. | |
| Result | bind (SocketIPAddress nativeAddress, BindReuseAddress reuseAddress=BindReuseAddress::Enabled, BindStatus *outStatus=nullptr) |
| IP-address compatibility overload for bind. | |
| Result | listen (uint32_t numberOfWaitingConnections) |
| Start listening for incoming connections at a specific address / port combination (after bind) | |
| Result | accept (SocketFlags::AddressFamily addressFamily, SocketDescriptor &newClient) |
| Accepts a new client, blocking while waiting for it. | |
| Result | accept (SocketDescriptor &newClient, SocketAddress *peerAddress=nullptr) |
| Accepts a new client and optionally reports its peer address. | |
Use a SocketDescriptor as a Server (example TCP or UDP Socket Server).
Example:
|
inline |
Build a SocketServer from a SocketDescriptor (already created with SocketDescriptor::create)
| socket | A socket descriptor created with SocketDescriptor::create to be used as server |
| Result SC::SocketServer::accept | ( | SocketDescriptor & | newClient, |
| SocketAddress * | peerAddress = nullptr ) |
Accepts a new client and optionally reports its peer address.
| Result SC::SocketServer::accept | ( | SocketFlags::AddressFamily | addressFamily, |
| SocketDescriptor & | newClient ) |
Accepts a new client, blocking while waiting for it.
| [in] | addressFamily | Compatibility parameter; the accepted descriptor family is inherited from the listener |
| [out] | newClient | The SocketDescriptor that will be accepted |
| Result SC::SocketServer::bind | ( | const SocketAddress & | nativeAddress, |
| BindReuseAddress | reuseAddress = BindReuseAddress::Enabled, | ||
| BindStatus * | outStatus = nullptr ) |
Binds this socket to an address.
| nativeAddress | The local address to bind |
| reuseAddress | Whether SO_REUSEADDR should be set before binding |
| outStatus | Optional detailed status for bind failures |
| Result SC::SocketServer::bind | ( | SocketIPAddress | nativeAddress, |
| BindReuseAddress | reuseAddress = BindReuseAddress::Enabled, | ||
| BindStatus * | outStatus = nullptr ) |
IP-address compatibility overload for bind.
| Result SC::SocketServer::close | ( | ) |
Calls SocketDescriptor::close.
| Result SC::SocketServer::listen | ( | uint32_t | numberOfWaitingConnections | ) |
Start listening for incoming connections at a specific address / port combination (after bind)
| numberOfWaitingConnections | How many connections can be queued before accept |