Preliminary. ThinkMeta ConcurrentTasks and this documentation are preliminary; everything is subject to change.

API reference / Async I/O

AsyncSocket class

A socket for overlapped I/O from tasks.

Use
import ThinkMeta.ConcurrentTasks.AsyncIo.AsyncSocket;
Namespace
ThinkMeta::ConcurrentTasks::AsyncIo
Inherits
Socket

Syntax

class AsyncSocket : public Windows::Socket

Remarks

Create associates it with the core's completion port, and each operation is offered as a starting form (XxxAsync) and a waiting form (Xxx). Preconditions: Windows::Socket::Startup (WSAStartup plus the AcceptEx/ConnectEx/... extension pointers) and EnableAsyncIo must have succeeded before Create, and the socket must be created through this class's Create (directly or through AsyncTcpSocket/AsyncIpSocket), otherwise no completion ever arrives. XxxAsync(..., asyncIoRequest) starts the operation and never suspends; it may be called from a task or a plain thread. The result is - Windows::WinsockError::Success: the operation completed synchronously. The request has already been completed (AsyncSocketIoRequest::RequestCompleted ran on the calling thread before the return); the core sets FILE_SKIP_COMPLETION_PORT_ON_SUCCESS on the handle, so no completion packet follows. - Windows::WinsockError::Pending: the operation is in flight; RequestCompleted is called later on the core's I/O thread with the operation's own error code. - any other WSA code: the operation failed synchronously; the request is not completed. The caller owns the request (AsyncSocketIoRequest) and every buffer (and address/WSAMSG structure) passed in; all of them must stay valid and must not move until the request has completed. A request is reused only after it has completed and been reset (AsyncIoRequest::Reset). Xxx(..., timeout) runs the same operation with a WaitableAsyncSocketIoRequest_s on its own stack and suspends the calling task until it has completed (the thread runs other tasks meanwhile), so it must be called from a task. It returns the operation's final WSA code; *bytesTransferred is set to 0 on failure. A finite timeout needs EnableTimers (without it the wait has no limit). On expiry the operation is cancelled (CancelIoEx), the call still waits until the cancellation has completed, and Windows::WinsockError::TimedOut is returned; if the operation completed before the cancellation took effect, its own result stands. After a cancelled operation a stream socket is fit for closing only (data may have been lost). Errors are reported as Windows::WinsockErrorCode (WSA* values); nothing throws. Several operations may be outstanding at once (e.g. one receive and one send), each with its own request, started from any tasks or threads. Close or destroy the socket only when no operation is pending any more (cancel with CancelAsyncRequest/Windows::Socket::CancelAllAsyncRequests and wait for the completions first).

See also

Windows::Socket, AsyncSocketIoRequest

Methods

Create

Creates the socket and associates it with the core's completion port.

Syntax

WinsockErrorCode Create(
    int addressFamily,
    int type,
    int protocol,
    WSAPROTOCOL_INFO* protocolInfo = nullptr,
    GROUP g = 0,
    DWORD flags = 0
) noexcept;

Parameters

addressFamilyint
The address family, e.g. AF_INET or AF_INET6.
typeint
The socket type, e.g. SOCK_STREAM or SOCK_DGRAM.
protocolint
The protocol, e.g. IPPROTO_TCP or IPPROTO_UDP; 0 lets the provider choose for the family and type.
protocolInfoWSAPROTOCOL_INFO*
Optional WSAPROTOCOL_INFO selecting the provider (as for WSASocket); nullptr (the default) uses addressFamily, type and protocol. Only read during the call.Default: nullptr
gGROUP
The Winsock socket group; 0 (the default) for none.Default: 0
flagsDWORD
Further WSA_FLAG_* flags for WSASocket, e.g. WSA_FLAG_NO_HANDLE_INHERIT; 0 (the default) for none. WSA_FLAG_OVERLAPPED is always added.Default: 0

Return value

Type: WinsockErrorCode

WinsockError::Success, the WSA error of WSASocket, or the error of the association with the completion port (then the new socket has been closed again and the object holds none).

Remarks

Parameters as WSASocket; WSA_FLAG_OVERLAPPED is added to flags. The object must not hold a socket yet. Needs Windows::Socket::Startup and EnableAsyncIo.

See also

Windows::Socket::Close

AcceptAsync

Starts an AcceptEx on this listening socket.

Syntax

WinsockErrorCode AcceptAsync(
    Socket& acceptSocket,
    void* outputBuffer,
    DWORD receiveDataLength,
    DWORD localAddressLength,
    DWORD remoteAddressLength,
    DWORD* bytesReceived,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

acceptSocketSocket&
Takes the accepted connection. A created, unbound and unconnected socket. For later asynchronous I/O it must be an AsyncSocket created through Create.
outputBuffervoid*
Receives the first receiveDataLength bytes of data followed by the local and remote address (parse with GetAcceptExSockaddrs). Must stay valid until completion.
receiveDataLengthDWORD
Bytes of initial data to wait for; 0 completes as soon as a connection arrives, otherwise only after that data (or the connection's end).
localAddressLengthDWORD
Space reserved for the local address: at least the address size + 16.
remoteAddressLengthDWORD
Space reserved for the remote address: at least the address size + 16.
bytesReceivedDWORD*
Required. Receives the byte count on synchronous completion.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

After the accept has completed, call acceptSocket.Windows::Socket::SetOptionUpdateAcceptContext(*this) before getpeername/shutdown etc. are used on it; AsyncTcpSocket::Accept does that.

See also

Accept, AsyncSocketIoRequest

Accept

Accepts a connection on this listening socket (AcceptEx).

Syntax

WinsockErrorCode Accept(
    Socket& acceptSocket,
    void* outputBuffer,
    DWORD receiveDataLength,
    DWORD localAddressLength,
    DWORD remoteAddressLength,
    DWORD* bytesReceived,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

acceptSocketSocket&
Takes the accepted connection. A created, unbound and unconnected socket. For later asynchronous I/O it must be an AsyncSocket created through Create.
outputBuffervoid*
Receives the first receiveDataLength bytes of data followed by the local and remote address (parse with GetAcceptExSockaddrs).
receiveDataLengthDWORD
Bytes of initial data to wait for; 0 completes as soon as a connection arrives, otherwise only after that data (or the connection's end).
localAddressLengthDWORD
Space reserved for the local address: at least the address size + 16.
remoteAddressLengthDWORD
Space reserved for the remote address: at least the address size + 16.
bytesReceivedDWORD*
Required. Receives the bytes of initial data received once the accept has completed (0 on failure).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until a connection has been accepted into acceptSocket. Does not set SO_UPDATE_ACCEPT_CONTEXT; call acceptSocket.Windows::Socket::SetOptionUpdateAcceptContext(*this) afterwards (or use AsyncTcpSocket::Accept).

See also

AcceptAsync

ConnectAsync

Starts a ConnectEx.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode ConnectAsync(
    const _SockAddr* addr,
    int addrSize,
    void* sendBuffer,
    DWORD sendDataLength,
    DWORD* bytesSent,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

addrconst _SockAddr*
Required. The address to connect to.
addrSizeint
The size of the actual address at addr (e.g. sizeof(sockaddr_in) for an IPv4 address held in a sockaddr_storage).
sendBuffervoid*
Optional data sent after the connection is established; may be nullptr. Must stay valid until the operation has completed.
sendDataLengthDWORD
Bytes to send from sendBuffer; 0 without it.
bytesSentDWORD*
Required when sendBuffer is given; receives the bytes sent on synchronous completion.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

Connection-oriented sockets only. ConnectEx needs a bound socket: Windows::Socket::Bind (e.g. to the any address, port 0) first, otherwise it fails with WSAEINVAL. After the connect has completed, call Windows::Socket::SetOptionUpdateConnectContext (AsyncTcpSocket::Connect does that).

See also

Connect

Connect

Connects with ConnectEx.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode Connect(
    const _SockAddr* addr,
    int addrSize,
    void* sendBuffer,
    DWORD sendDataLength,
    DWORD* bytesSent,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

addrconst _SockAddr*
Required. The address to connect to.
addrSizeint
The size of the actual address at addr (e.g. sizeof(sockaddr_in) for an IPv4 address held in a sockaddr_storage).
sendBuffervoid*
Optional data sent after the connection is established; may be nullptr.
sendDataLengthDWORD
Bytes to send from sendBuffer; 0 without it.
bytesSentDWORD*
Required when sendBuffer is given; receives the bytes sent once connected (0 on failure).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until connected. The socket must be bound. Does not set SO_UPDATE_CONNECT_CONTEXT; call Windows::Socket::SetOptionUpdateConnectContext afterwards (or use AsyncTcpSocket::Connect).

See also

ConnectAsync

DisconnectAsync

Starts a DisconnectEx on a connected socket.

Syntax

WinsockErrorCode DisconnectAsync(
    AsyncSocketIoRequest& asyncIoRequest,
    DWORD flags = 0
) noexcept;

Parameters

asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.
flagsDWORD
0 or TF_REUSE_SOCKET (the socket can then be passed to AcceptAsync/ ConnectAsync again).Default: 0

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

See also

Disconnect

Disconnect

Disconnects with DisconnectEx.

Syntax

WinsockErrorCode Disconnect(
    DWORD flags = 0,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

flagsDWORD
0 (the default) or TF_REUSE_SOCKET (the socket can then be passed to Accept/ Connect again).Default: 0
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

DisconnectAsync

GetOverlappedResult

Reads the result of an operation without waiting.

Syntax

WinsockErrorCode GetOverlappedResult(
    AsyncSocketIoRequest& asyncIoRequest,
    DWORD* bytesTransferred,
    DWORD* flags
) noexcept;

Parameters

asyncIoRequestAsyncSocketIoRequest&
The request the operation was started with.
bytesTransferredDWORD*
Required. Receives the bytes transferred.
flagsDWORD*
Receives the operation's result flags.

Return value

Type: WinsockErrorCode

WinsockError::Success, WSA_IO_INCOMPLETE while still pending, or the operation's error.

Remarks

WSAGetOverlappedResult with fWait = false.

CancelAsyncRequest

Requests cancellation of one operation (CancelIoEx).

Syntax

WinsockErrorCode CancelAsyncRequest(AsyncSocketIoRequest& asyncIoRequest) noexcept;

Parameters

asyncIoRequestAsyncSocketIoRequest&
The request the operation was started with.

Return value

Type: WinsockErrorCode

WinsockError::Success if cancellation was requested, ERROR_NOT_FOUND if the operation was no longer pending, or another error.

Remarks

Does not wait: the request still completes, normally with WinsockError::OperationAborted, or with its own result if it finished first. Keep the request and its buffers alive until then. After a cancelled operation a stream socket is fit for closing only.

See also

Windows::Socket::CancelAllAsyncRequests

RecvAsync

Starts a WSARecv.

Syntax

WinsockErrorCode RecvAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD* flags,
    AsyncSocketRecvIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call. The result flags (e.g. MSG_PARTIAL) are stored in asyncIoRequest (AsyncSocketRecvIoRequest::GetFlags) once the operation has completed.
asyncIoRequestAsyncSocketRecvIoRequest&
The caller-owned receive request that is completed with the operation's result and keeps its result flags. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

On a stream socket, a completion with WinsockError::Success and 0 bytes means the peer closed the connection.

See also

Recv, AsyncSocketRecvIoRequest

Starts a WSARecv without flags.

Syntax

WinsockErrorCode RecvAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

See the overload with flags.

Starts a WSARecv into one buffer.

Syntax

WinsockErrorCode RecvAsync(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD* flags,
    AsyncSocketRecvIoRequest& asyncIoRequest
) noexcept;

Parameters

buffervoid*
The receive buffer; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call. The result flags (e.g. MSG_PARTIAL) are stored in asyncIoRequest (AsyncSocketRecvIoRequest::GetFlags) once the operation has completed.
asyncIoRequestAsyncSocketRecvIoRequest&
The caller-owned receive request that is completed with the operation's result and keeps its result flags. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

See the WSABUF overload.

Starts a WSARecv into one buffer without flags.

Syntax

WinsockErrorCode RecvAsync(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffervoid*
The receive buffer; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

See the WSABUF overload.

Recv

Receives with WSARecv.

Syntax

WinsockErrorCode Recv(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD* flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call; out on success: the result flags (e.g. MSG_PARTIAL).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task. WinsockError::Success with 0 bytes on a stream socket: the peer closed the connection.

See also

RecvAsync

Receives with WSARecv without flags.

Syntax

WinsockErrorCode Recv(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task. WinsockError::Success with 0 bytes on a stream socket: the peer closed the connection.

Receives into one buffer with WSARecv.

Syntax

WinsockErrorCode Recv(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD* flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffervoid*
The receive buffer.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call; out on success: the result flags (e.g. MSG_PARTIAL).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task. WinsockError::Success with 0 bytes on a stream socket: the peer closed the connection.

Receives into one buffer with WSARecv without flags.

Syntax

WinsockErrorCode Recv(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffervoid*
The receive buffer.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task. WinsockError::Success with 0 bytes on a stream socket: the peer closed the connection. With a timeout, a receive that times out is cancelled and returns WinsockError::TimedOut.

SendAsync

Starts a WSASend.

Syntax

WinsockErrorCode SendAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD flags,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
flagsDWORD
MSG_* flags for WSASend (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

See also

Send

Starts a WSASend without flags.

Syntax

WinsockErrorCode SendAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASend of one buffer.

Syntax

WinsockErrorCode SendAsync(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD flags,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

bufferconst void*
The data to send; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
flagsDWORD
MSG_* flags for WSASend (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

The buffer must stay valid until completion.

Starts a WSASend of one buffer without flags.

Syntax

WinsockErrorCode SendAsync(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

bufferconst void*
The data to send; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

The buffer must stay valid until completion.

Send

Sends with WSASend.

Syntax

WinsockErrorCode Send(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
flagsDWORD
MSG_* flags for WSASend (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

SendAsync

Sends with WSASend without flags.

Syntax

WinsockErrorCode Send(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends one buffer with WSASend.

Syntax

WinsockErrorCode Send(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

bufferconst void*
The data to send.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
flagsDWORD
MSG_* flags for WSASend (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends one buffer with WSASend without flags.

Syntax

WinsockErrorCode Send(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

bufferconst void*
The data to send.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

RecvFromAsync

Starts a WSARecvFrom without capturing the sender's address.

Syntax

WinsockErrorCode RecvFromAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD* flags,
    AsyncSocketRecvIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call. The result flags (e.g. MSG_PARTIAL) are stored in asyncIoRequest (AsyncSocketRecvIoRequest::GetFlags) once the operation has completed.
asyncIoRequestAsyncSocketRecvIoRequest&
The caller-owned receive request that is completed with the operation's result and keeps its result flags. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

See also

RecvFrom, AsyncSocketRecvIoRequest

Starts a WSARecvFrom without flags or sender address.

Syntax

WinsockErrorCode RecvFromAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSARecvFrom into one buffer without capturing the sender's address.

Syntax

WinsockErrorCode RecvFromAsync(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD* flags,
    AsyncSocketRecvIoRequest& asyncIoRequest
) noexcept;

Parameters

buffervoid*
The receive buffer; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call. The result flags (e.g. MSG_PARTIAL) are stored in asyncIoRequest (AsyncSocketRecvIoRequest::GetFlags) once the operation has completed.
asyncIoRequestAsyncSocketRecvIoRequest&
The caller-owned receive request that is completed with the operation's result and keeps its result flags. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSARecvFrom into one buffer without flags or sender address.

Syntax

WinsockErrorCode RecvFromAsync(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffervoid*
The receive buffer; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSARecvFrom with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFromAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD* flags,
    _SockAddr& addr,
    int& addrLength,
    AsyncSocketRecvIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call. The result flags (e.g. MSG_PARTIAL) are stored in asyncIoRequest (AsyncSocketRecvIoRequest::GetFlags) once the operation has completed.
addr_SockAddr&
Receives the sender's address on completion; must stay valid until then.
addrLengthint&
Receives the size of the sender's address in bytes on completion; must stay valid until then.
asyncIoRequestAsyncSocketRecvIoRequest&
The caller-owned receive request that is completed with the operation's result and keeps its result flags. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSARecvFrom without flags, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFromAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    _SockAddr& addr,
    int& addrLength,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
addr_SockAddr&
Receives the sender's address on completion; must stay valid until then.
addrLengthint&
Receives the size of the sender's address in bytes on completion; must stay valid until then.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

addr (the sender's address) and addrLength are written at completion and must stay valid until then.

Starts a WSARecvFrom into one buffer, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFromAsync(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD* flags,
    _SockAddr& addr,
    int& addrLength,
    AsyncSocketRecvIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffervoid*
The receive buffer; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call. The result flags (e.g. MSG_PARTIAL) are stored in asyncIoRequest (AsyncSocketRecvIoRequest::GetFlags) once the operation has completed.
addr_SockAddr&
Receives the sender's address on completion; must stay valid until then.
addrLengthint&
Receives the size of the sender's address in bytes on completion; must stay valid until then.
asyncIoRequestAsyncSocketRecvIoRequest&
The caller-owned receive request that is completed with the operation's result and keeps its result flags. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSARecvFrom into one buffer without flags, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFromAsync(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    _SockAddr& addr,
    int& addrLength,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffervoid*
The receive buffer; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
addr_SockAddr&
Receives the sender's address on completion; must stay valid until then.
addrLengthint&
Receives the size of the sender's address in bytes on completion; must stay valid until then.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

The buffer, addr (the sender's address) and addrLength are written at completion and must stay valid until then.

RecvFrom

Receives with WSARecvFrom.

Syntax

WinsockErrorCode RecvFrom(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD* flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call; out on success: the result flags (e.g. MSG_PARTIAL).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

RecvFromAsync

Receives with WSARecvFrom without flags or sender address.

Syntax

WinsockErrorCode RecvFrom(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Receives into one buffer with WSARecvFrom.

Syntax

WinsockErrorCode RecvFrom(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD* flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffervoid*
The receive buffer.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call; out on success: the result flags (e.g. MSG_PARTIAL).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Receives into one buffer with WSARecvFrom without flags or sender address.

Syntax

WinsockErrorCode RecvFrom(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffervoid*
The receive buffer.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Receives with WSARecvFrom, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFrom(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD* flags,
    _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call; out on success: the result flags (e.g. MSG_PARTIAL).
addr_SockAddr&
Receives the sender's address once the operation has completed.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Receives with WSARecvFrom without flags, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFrom(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the receive buffers.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
addr_SockAddr&
Receives the sender's address once the operation has completed.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Receives into one buffer with WSARecvFrom, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFrom(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD* flags,
    _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffervoid*
The receive buffer.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
flagsDWORD*
Required. In: MSG_* flags for the call; out on success: the result flags (e.g. MSG_PARTIAL).
addr_SockAddr&
Receives the sender's address once the operation has completed.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Receives into one buffer with WSARecvFrom without flags, with the sender's address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode RecvFrom(
    void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffervoid*
The receive buffer.
bufferSizestd::uint32_t
Size of buffer in bytes.
bytesTransferredDWORD*
Receives the bytes received once the operation has completed (0 on failure); may be nullptr.
addr_SockAddr&
Receives the sender's address once the operation has completed.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

SendToAsync

Starts a WSASendTo without address.

Syntax

WinsockErrorCode SendToAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD flags,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

Sends to the connected/default peer.

See also

SendTo

Starts a WSASendTo without address or flags.

Syntax

WinsockErrorCode SendToAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASendTo of one buffer without address.

Syntax

WinsockErrorCode SendToAsync(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD flags,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

bufferconst void*
The data to send; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASendTo of one buffer without address or flags.

Syntax

WinsockErrorCode SendToAsync(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

bufferconst void*
The data to send; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASendTo to an address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendToAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD flags,
    const _SockAddr& addr,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr; must stay valid until the operation has completed.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASendTo to an address without flags.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendToAsync(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    const _SockAddr& addr,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send. The array may be temporary; the memory it describes must stay valid until the operation has completed.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr; must stay valid until the operation has completed.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASendTo of one buffer to an address.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendToAsync(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD flags,
    const _SockAddr& addr,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

bufferconst void*
The data to send; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr; must stay valid until the operation has completed.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Starts a WSASendTo of one buffer to an address without flags.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendToAsync(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    const _SockAddr& addr,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

bufferconst void*
The data to send; must stay valid until the operation has completed.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr; must stay valid until the operation has completed.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

SendTo

Sends with WSASendTo without address.

Syntax

WinsockErrorCode SendTo(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

SendToAsync

Sends with WSASendTo without address or flags.

Syntax

WinsockErrorCode SendTo(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends one buffer with WSASendTo without address.

Syntax

WinsockErrorCode SendTo(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD flags,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

bufferconst void*
The data to send.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends one buffer with WSASendTo without address or flags.

Syntax

WinsockErrorCode SendTo(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

bufferconst void*
The data to send.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends to an address with WSASendTo.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendTo(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    DWORD flags,
    const _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends to an address with WSASendTo without flags.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendTo(
    WSABUF* buffers,
    DWORD bufferCount,
    DWORD* bytesTransferred,
    const _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

buffersWSABUF*
Array of bufferCount WSABUF structures describing the data to send.
bufferCountDWORD
Number of WSABUF structures in buffers.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends one buffer to an address with WSASendTo.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendTo(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    DWORD flags,
    const _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

bufferconst void*
The data to send.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
flagsDWORD
MSG_* flags for WSASendTo (e.g. MSG_DONTROUTE, MSG_OOB); 0 for none.
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

Sends one buffer to an address with WSASendTo without flags.

Syntax

template <Windows::SockAddrType _SockAddr>
WinsockErrorCode SendTo(
    const void* buffer,
    std::uint32_t bufferSize,
    DWORD* bytesTransferred,
    const _SockAddr& addr,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_SockAddrWindows::SockAddrType
The address type (Windows::SockAddrType): sockaddr, sockaddr_in, sockaddr_in6 or sockaddr_storage.

Parameters

bufferconst void*
The data to send.
bufferSizestd::uint32_t
Number of bytes to send from buffer.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
addrconst _SockAddr&
The destination address, passed with the size of _SockAddr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

RecvMsgAsync

Starts a WSARecvMsg.

Syntax

WinsockErrorCode RecvMsgAsync(
    WSAMSG* msg,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

msgWSAMSG*
Buffers, name and control space; WSARecvMsg writes into it at completion, so it must stay valid until then.
bytesTransferredDWORD*
Required. Receives the bytes received on synchronous completion.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

For datagram/raw sockets; needs Windows::Socket::Startup for the extension pointer.

See also

RecvMsg

RecvMsg

Receives with WSARecvMsg.

Syntax

WinsockErrorCode RecvMsg(
    WSAMSG* msg,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

msgWSAMSG*
Buffers, name and control space; WSARecvMsg fills it in once the operation has completed.
bytesTransferredDWORD*
Required. Receives the bytes received once the operation has completed (0 on failure).
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

RecvMsgAsync

SendMsgAsync

Starts a WSASendMsg.

Syntax

WinsockErrorCode SendMsgAsync(
    WSAMSG* msg,
    DWORD flags,
    DWORD* bytesTransferred,
    AsyncSocketIoRequest& asyncIoRequest
) noexcept;

Parameters

msgWSAMSG*
The message (buffers, destination, control data); it and the memory it describes must stay valid until completion.
flagsDWORD
MSG_* flags for WSASendMsg (e.g. MSG_DONTROUTE); 0 for none.
bytesTransferredDWORD*
Receives the bytes sent on synchronous completion; may be nullptr (the request then takes the count from the completed operation).
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

See also

SendMsg

SendMsg

Sends with WSASendMsg.

Syntax

WinsockErrorCode SendMsg(
    WSAMSG* msg,
    DWORD flags,
    DWORD* bytesTransferred,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

msgWSAMSG*
The message (buffers, destination, control data).
flagsDWORD
MSG_* flags for WSASendMsg (e.g. MSG_DONTROUTE); 0 for none.
bytesTransferredDWORD*
Receives the bytes sent once the operation has completed (0 on failure); may be nullptr.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

SendMsgAsync

TransmitFileAsync

Starts a TransmitFile on a connected socket.

Syntax

WinsockErrorCode TransmitFileAsync(
    HANDLE file,
    DWORD bytesToWrite,
    DWORD bytesPerSend,
    TRANSMIT_FILE_BUFFERS* transmitBuffers,
    AsyncSocketIoRequest& asyncIoRequest,
    DWORD flags = 0
) noexcept;

Parameters

fileHANDLE
The open file to send; nullptr sends only transmitBuffers. Sending starts at the file offset in the request's OVERLAPPED (0 after construction or AsyncIoRequest::Reset).
bytesToWriteDWORD
Bytes of the file to send; 0 sends the whole file.
bytesPerSendDWORD
Size of each send; 0 lets the system choose.
transmitBuffersTRANSMIT_FILE_BUFFERS*
Optional head/tail data; must stay valid until completion.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.
flagsDWORD
TF_* flags, e.g. TF_DISCONNECT | TF_REUSE_SOCKET; 0 (the default) for none.Default: 0

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

Remarks

The file handle stays owned by the caller and must stay open until completion.

See also

TransmitFile

TransmitFile

Sends a file with TransmitFile.

Syntax

WinsockErrorCode TransmitFile(
    HANDLE file,
    DWORD bytesToWrite,
    DWORD bytesPerSend,
    TRANSMIT_FILE_BUFFERS* transmitBuffers,
    DWORD flags = 0,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

fileHANDLE
The open file to send, starting at offset 0; nullptr sends only transmitBuffers.
bytesToWriteDWORD
Bytes of the file to send; 0 sends the whole file.
bytesPerSendDWORD
Size of each send; 0 lets the system choose.
transmitBuffersTRANSMIT_FILE_BUFFERS*
Optional head/tail data; may be nullptr.
flagsDWORD
TF_* flags, e.g. TF_DISCONNECT | TF_REUSE_SOCKET; 0 (the default) for none.Default: 0
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed. The file handle stays owned by the caller.

See also

TransmitFileAsync

TransmitPacketsAsync

Starts a TransmitPackets on a connected socket.

Syntax

WinsockErrorCode TransmitPacketsAsync(
    TRANSMIT_PACKETS_ELEMENT* packetArray,
    DWORD elementCount,
    DWORD transmitSize,
    AsyncSocketIoRequest& asyncIoRequest,
    DWORD flags = 0
) noexcept;

Parameters

packetArrayTRANSMIT_PACKETS_ELEMENT*
The elements (memory and/or file ranges); they and everything they reference must stay valid until completion.
elementCountDWORD
Number of elements in packetArray.
transmitSizeDWORD
Bytes per send; 0 lets the system choose.
asyncIoRequestAsyncSocketIoRequest&
The caller-owned request that is completed with the operation's result. It must not be in use by another operation and must stay valid and must not move until it has completed.
flagsDWORD
TF_* flags, e.g. TF_DISCONNECT | TF_REUSE_SOCKET; 0 (the default) for none.Default: 0

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::Pending or the WSA error (see the class remarks).

See also

TransmitPackets

TransmitPackets

Sends packets with TransmitPackets.

Syntax

WinsockErrorCode TransmitPackets(
    TRANSMIT_PACKETS_ELEMENT* packetArray,
    DWORD elementCount,
    DWORD transmitSize,
    DWORD flags = 0,
    Duration timeout = Duration::Infinite()
) noexcept;

Parameters

packetArrayTRANSMIT_PACKETS_ELEMENT*
The elements (memory and/or file ranges) to send.
elementCountDWORD
Number of elements in packetArray.
transmitSizeDWORD
Bytes per send; 0 lets the system choose.
flagsDWORD
TF_* flags, e.g. TF_DISCONNECT | TF_REUSE_SOCKET; 0 (the default) for none.Default: 0
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the operation's WSA error.

Remarks

Task only; suspends the calling task until the operation has completed.

See also

TransmitPacketsAsync

HandleCompletedRequestprotected

Finishes the start of an operation.

Syntax

template <AsyncSocketIoRequestType _Request>
WinsockErrorCode HandleCompletedRequest(
    WinsockErrorCode error,
    DWORD* bytesTransferred,
    _Request& asyncIoRequest
) noexcept;

Template parameters

_RequestAsyncSocketIoRequestType
The request type (AsyncSocketIoRequestType); a receive request (AsyncSocketRecvIoRequest) also gets its result flags.

Parameters

errorWinsockErrorCode
The result of the starting call: WinsockError::Success, WinsockError::Pending or a synchronous WSA error.
bytesTransferredDWORD*
The count the starting call wrote, or nullptr. A receive request (AsyncSocketRecvIoRequest) fetches the count and the result flags itself (and stores the count here if given); any other request is completed with *bytesTransferred, or without it with the count fetched from the operation.
asyncIoRequest_Request&
The request the operation was started with; completed in place on synchronous success.

Return value

Type: WinsockErrorCode

If error is WinsockError::Success (synchronous completion), completes asyncIoRequest in place and returns Success; otherwise returns error unchanged (WinsockError::Pending or a synchronous failure).

WaitForAsyncIoOperationprotected

Waits for an operation started with asyncIoRequest.

Syntax

template <WaitableAsyncSocketIoRequestType _Request>
WinsockErrorCode WaitForAsyncIoOperation(
    WinsockErrorCode error,
    DWORD* bytesTransferred,
    _Request& asyncIoRequest,
    Duration timeout = Duration::Infinite()
) noexcept;

Template parameters

_RequestWaitableAsyncSocketIoRequestType
The waitable request type (WaitableAsyncSocketIoRequestType), e.g. WaitableAsyncSocketIoRequest_s.

Parameters

errorWinsockErrorCode
The result of the starting XxxAsync call; only WinsockError::Pending waits.
bytesTransferredDWORD*
Receives the request's transferred bytes on success, 0 on failure; may be nullptr.
asyncIoRequest_Request&
The request the operation was started with; must live in the caller's frame until this returns.
timeoutDuration
Maximum time to wait; Duration::Infinite (the default) waits without limit. A finite timeout needs EnableTimers; on expiry the operation is cancelled.Default: Duration::Infinite()

Return value

Type: WinsockErrorCode

The operation's final error: WinsockError::Success, WinsockError::TimedOut if timeout expired and the operation was cancelled, or the WSA error.

Remarks

If error is WinsockError::Pending, suspends the calling task until the request completes (or timeout expires, then cancels and returns WinsockError::TimedOut, see the class remarks); then stores the bytes transferred (0 on failure). Task only. The request must live in the caller's frame until this returns.

Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).