Starts a socket accept operation, obtaining a new socket from a listening socket. More...
#include <Async.h>
Classes | |
struct | CompletionData |
Completion data for AsyncSocketAccept. More... | |
struct | Result |
Callback result for AsyncSocketAccept. More... | |
Public Member Functions | |
SC::Result | start (AsyncEventLoop &eventLoop, const SocketDescriptor &socketDescriptor) |
Starts a socket accept operation, that returns a new socket connected to the given listening endpoint. More... | |
Public Member Functions inherited from SC::AsyncRequest | |
void | setDebugName (const char *newDebugName) |
AsyncEventLoop * | getEventLoop () const |
Get the event loop associated with this AsyncRequest. More... | |
void | cacheInternalEventLoop (AsyncEventLoop &loop) |
Caches the event loop associated with this AsyncRequest. More... | |
AsyncRequest (Type type) | |
Constructs a free async request of given type. More... | |
Result | stop () |
Stops the async operation. More... | |
bool | isFree () const |
Public Attributes | |
Function< void(Result &)> | callback |
Called when a new socket has been accepted. More... | |
Public Attributes inherited from SC::AsyncRequest | |
AsyncRequest * | next = nullptr |
AsyncRequest * | prev = nullptr |
Friends | |
struct | AsyncEventLoop |
Additional Inherited Members | |
Public Types inherited from SC::AsyncRequest | |
enum class | Type : uint8_t { LoopTimeout , LoopWakeUp , LoopWork , ProcessExit , SocketAccept , SocketConnect , SocketSend , SocketReceive , SocketClose , FileRead , FileWrite , FileClose , FilePoll } |
Type of async request. More... | |
Protected Member Functions inherited from SC::AsyncRequest | |
Result | validateAsync () |
Result | queueSubmission (AsyncEventLoop &eventLoop) |
Result | queueSubmission (AsyncEventLoop &eventLoop, ThreadPool &threadPool, AsyncTask &task) |
Protected Attributes inherited from SC::AsyncRequest | |
AsyncEventLoop * | eventLoop = nullptr |
AsyncTask * | asyncTask = nullptr |
Starts a socket accept operation, obtaining a new socket from a listening socket.
The callback is called with a new socket connected to the given listening endpoint will be returned.
Socket library can be used to create a Socket but the socket should be created with SC::SocketFlags::NonBlocking and associated to the event loop with SC::AsyncEventLoop::associateExternallyCreatedTCPSocket.
Alternatively SC::AsyncEventLoop::createAsyncTCPSocket creates and associates the socket to the loop.
SC::Result SC::AsyncSocketAccept::start | ( | AsyncEventLoop & | eventLoop, |
const SocketDescriptor & | socketDescriptor | ||
) |
Starts a socket accept operation, that returns a new socket connected to the given listening endpoint.
eventLoop | The event loop where queuing this async request |
socketDescriptor | The socket that will receive the accepted client. |