Starts a socket receive operation, receiving bytes from a remote endpoint. More...
#include <Async.h>
Classes | |
| struct | CompletionData |
| struct | Result |
Public Member Functions | |
| SC::Result | start (AsyncEventLoop &eventLoop, const SocketDescriptor &descriptor, Span< char > data) |
| Sets async request members and calls AsyncEventLoop::start. | |
| Result | start (AsyncEventLoop &eventLoop) |
| Shortcut for AsyncEventLoop::start. | |
Public Member Functions inherited from SC::AsyncRequest | |
| void | setDebugName (const char *newDebugName) |
| void | executeOn (AsyncSequence &sequence) |
| Adds the request to be executed on a specific AsyncSequence. | |
| Result | executeOn (AsyncTaskSequence &task, ThreadPool &pool) |
| Adds the request to be executed on a specific AsyncTaskSequence. | |
| void | disableThreadPool () |
| Disables the thread-pool usage for this request. | |
| AsyncRequest (Type type) | |
| Constructs a free async request of given type. | |
| Result | stop (AsyncEventLoop &eventLoop, Function< void(AsyncResult &)> *afterStopped=nullptr) |
| Ask to stop current async operation. | |
| bool | isFree () const |
Returns true if this request is free. | |
| bool | isCancelling () const |
Returns true if this request is being cancelled. | |
| bool | isActive () const |
Returns true if this request is active or being reactivated. | |
| Type | getType () const |
| Returns request type. | |
| Result | start (AsyncEventLoop &eventLoop) |
| Shortcut for AsyncEventLoop::start. | |
| void | setUserFlags (uint16_t externalFlags) |
| Sets user flags, holding some meaningful data for the caller. | |
| uint16_t | getUserFlags () const |
| Gets user flags, holding some meaningful data for the caller. | |
| Function< void(AsyncResult &)> * | getCloseCallback () |
| Returns currently set close callback (if any) passed to AsyncRequest::stop. | |
| const Function< void(AsyncResult &)> * | getCloseCallback () const |
Public Attributes | |
| Function< void(Result &)> | callback |
| Called after data has been received. | |
| Span< char > | buffer |
| The writeable span of memory where to data will be written. | |
| SocketDescriptor::Handle | handle = SocketDescriptor::Invalid |
Public Attributes inherited from SC::AsyncRequest | |
| AsyncRequest * | next = nullptr |
| AsyncRequest * | prev = nullptr |
Protected Member Functions | |
| AsyncSocketReceive (Type type) | |
| The Socket Descriptor handle to read data from. | |
| SC::Result | validate (AsyncEventLoop &) |
Protected Member Functions inherited from SC::AsyncRequest | |
| Result | checkState () |
| void | queueSubmission (AsyncEventLoop &eventLoop) |
| AsyncTaskSequence * | getTask () |
Friends | |
| struct | AsyncEventLoop |
Additional Inherited Members | |
Public Types inherited from SC::AsyncRequest | |
| enum class | Type : uint8_t { LoopTimeout , LoopWakeUp , LoopWork , ProcessExit , SocketAccept , SocketConnect , SocketSend , SocketSendTo , SocketReceive , SocketReceiveFrom , FileRead , FileWrite , FilePoll , FileSystemOperation } |
| Type of async request. More... | |
Protected Attributes inherited from SC::AsyncRequest | |
| AsyncSequence * | sequence = nullptr |
Starts a socket receive operation, receiving bytes from a remote endpoint.
Callback will be called when some data is read from socket.
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::associateExternallyCreatedSocket or though AsyncSocketAccept.
Alternatively SC::AsyncEventLoop::createAsyncTCPSocket creates and associates the socket to the loop.
Additional notes:
|
inlineprotected |
The Socket Descriptor handle to read data from.
| Result SC::AsyncRequest::start | ( | AsyncEventLoop & | eventLoop | ) |
Shortcut for AsyncEventLoop::start.
| SC::Result SC::AsyncSocketReceive::start | ( | AsyncEventLoop & | eventLoop, |
| const SocketDescriptor & | descriptor, | ||
| Span< char > | data ) |
Sets async request members and calls AsyncEventLoop::start.
| Span<char> SC::AsyncSocketReceive::buffer |
The writeable span of memory where to data will be written.