Use a SocketDescriptor as a Server (example TCP or UDP Socket Server).
More...
#include <Socket.h>
Use a SocketDescriptor as a Server (example TCP or UDP Socket Server).
Example:
constexpr int tcpPort = 5050;
SC_TRY(server.bind(nativeAddress));
SC_TRY(server.accept(family, acceptedClientSocket));
SC_TRY(acceptedClientSocket.isValid());
◆ SocketServer()
◆ accept()
Accepts a new client, blocking while waiting for it.
- Parameters
-
- Returns
- Valid Result if the socket has been successfully accepted
◆ bind()
Binds this socket to a given address / port combination.
- Parameters
-
nativeAddress | The interface ip address and port to start listening to |
- Returns
- Valid Result if this socket has successfully been bound
◆ close()
Result SC::SocketServer::close |
( |
| ) |
|
|
nodiscard |
◆ listen()
Result SC::SocketServer::listen |
( |
uint32_t | numberOfWaitingConnections | ) |
|
|
nodiscard |
Start listening for incoming connections at a specific address / port combination (after bind)
- Parameters
-
numberOfWaitingConnections | How many connections can be queued before accept |
- Returns
- Valid Result if this socket has successfully been put in listening mode
- Note
- UDP socket cannot be listened. TCP socket need a successful SocketServer::bind before SocketServer::listen
The documentation for this struct was generated from the following file: