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 (SocketIPAddress nativeAddress, BindReuseAddress reuseAddress=BindReuseAddress::Enabled, BindStatus *outStatus=nullptr) |
| Binds this socket to a given address / port combination. | |
| 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. | |
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 | ( | SocketFlags::AddressFamily | addressFamily, |
| SocketDescriptor & | newClient ) |
Accepts a new client, blocking while waiting for it.
| [in] | addressFamily | The address family of the SocketDescriptor that will be created |
| [out] | newClient | The SocketDescriptor that will be accepted |
| Result SC::SocketServer::bind | ( | SocketIPAddress | nativeAddress, |
| BindReuseAddress | reuseAddress = BindReuseAddress::Enabled, | ||
| BindStatus * | outStatus = nullptr ) |
Binds this socket to a given address / port combination.
| nativeAddress | The interface ip address and port to start listening to |
| reuseAddress | Whether SO_REUSEADDR should be set before binding |
| outStatus | Optional detailed status for bind failures |
| Result SC::SocketServer::close | ( | ) |
Calls SocketDescriptor::close.
Start listening for incoming connections at a specific address / port combination (after bind)
| numberOfWaitingConnections | How many connections can be queued before accept |