Starts a socket send operation, sending bytes to a remote endpoint. More...
#include <Async.h>
Classes | |
struct | CompletionData |
Completion data for AsyncSocketSend. More... | |
Public Types | |
using | Result = AsyncResultOf< AsyncSocketSend, CompletionData > |
Callback result for AsyncSocketSend. More... | |
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... | |
Public Member Functions | |
SC::Result | start (AsyncEventLoop &eventLoop, const SocketDescriptor &socketDescriptor, Span< const char > data) |
Starts a socket send operation. More... | |
SC::Result | start (AsyncEventLoop &eventLoop) |
Starts a socket send operation. 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 socket is ready to send more data. More... | |
Span< const char > | buffer |
Span of bytes to send. More... | |
SocketDescriptor::Handle | handle = SocketDescriptor::Invalid |
The socket to send data to. More... | |
Public Attributes inherited from SC::AsyncRequest | |
AsyncRequest * | next = nullptr |
AsyncRequest * | prev = nullptr |
Friends | |
struct | AsyncEventLoop |
Additional Inherited Members | |
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 send operation, sending bytes to a remote endpoint.
Callback will be called when the given socket is ready to send more data.
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 or though AsyncSocketAccept.
Alternatively SC::AsyncEventLoop::createAsyncTCPSocket creates and associates the socket to the loop.
Callback result for AsyncSocketSend.
SC::Result SC::AsyncSocketSend::start | ( | AsyncEventLoop & | eventLoop | ) |
Starts a socket send operation.
Callback will be called when the given socket is ready to send more data.
eventLoop | The event loop where queuing this async request |
SC::Result SC::AsyncSocketSend::start | ( | AsyncEventLoop & | eventLoop, |
const SocketDescriptor & | socketDescriptor, | ||
Span< const char > | data | ||
) |
Starts a socket send operation.
Callback will be called when the given socket is ready to send more data.
eventLoop | The event loop where queuing this async request |
socketDescriptor | The socket to send data to |
data | The data to be sent |
Called when socket is ready to send more data.
SocketDescriptor::Handle SC::AsyncSocketSend::handle = SocketDescriptor::Invalid |
The socket to send data to.