Starts a socket connect operation, connecting to a remote endpoint. More...
#include <Async.h>
Public Types | |
using | CompletionData = AsyncCompletionData |
Completion data for AsyncSocketConnect. More... | |
using | Result = AsyncResultOf< AsyncSocketConnect, CompletionData > |
Callback result for AsyncSocketConnect. 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, SocketIPAddress ipAddress) |
Starts a socket connect 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... | |
Result | setThreadPoolAndTask (ThreadPool &pool, AsyncTask &task) |
Sets the thread pool and task to use for this request. More... | |
void | resetThreadPoolAndTask () |
Resets anything previously set with setThreadPoolAndTask. 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 after socket is finally connected to endpoint. 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 () |
void | queueSubmission (AsyncEventLoop &eventLoop) |
Protected Attributes inherited from SC::AsyncRequest | |
AsyncEventLoop * | eventLoop = nullptr |
AsyncTask * | asyncTask = nullptr |
Starts a socket connect operation, connecting to a remote endpoint.
Callback will be called when the given socket is connected to ipAddress.
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.
Completion data for AsyncSocketConnect.
Callback result for AsyncSocketConnect.
SC::Result SC::AsyncSocketConnect::start | ( | AsyncEventLoop & | eventLoop, |
const SocketDescriptor & | socketDescriptor, | ||
SocketIPAddress | ipAddress | ||
) |
Starts a socket connect operation.
Callback will be called when the given socket is connected to ipAddress.
eventLoop | The event loop where queuing this async request |
socketDescriptor | The socket needing to connect to the ip address |
ipAddress | A valid ip address to connect to |
Called after socket is finally connected to endpoint.