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

API reference / Windows

WinsockError struct

Named Winsock error codes and helpers that turn Winsock return values into error codes.

On this page
Use
import ThinkMeta.ConcurrentTasks.Windows.WinsockError;
Namespace
ThinkMeta::ConcurrentTasks::Windows
Platforms
Windows

Syntax

Remarks

A WinsockErrorCode is Success (0) or the WSAGetLastError value. WSAGetLastError is thread-local and equal to GetLastError, so the helpers must run right after the failing call on the same thread. For completed overlapped operations the socket classes use the completion's own code instead.

See also

WinsockErrorException

Names

NameDescription
WinsockErrorCode A Winsock error code as returned by the socket classes (0 = WinsockError::Success).

Methods

GetError

The error of a call returning 0 on success.

Syntax

static Type GetError(int result) noexcept;

Parameters

resultint
The result of e.g. bind or WSARecv.

Return value

Type: Type

Success, or WSAGetLastError for any other result.

GetAsyncError

The error of a call returning BOOL.

Syntax

static Type GetAsyncError(BOOL result) noexcept;

Parameters

resultBOOL
The result of e.g. AcceptEx or ConnectEx.

Return value

Type: Type

Success if TRUE, else WSAGetLastError.

GetLastError

The calling thread's last Winsock error (WSAGetLastError).

Syntax

static Type GetLastError() noexcept;

Return value

Type: Type

The last error code; only meaningful right after a failed Winsock call on this thread.

FromOverlapped

The Winsock error of a completed overlapped operation.

Syntax

static Type FromOverlapped(const OVERLAPPED& overlapped, Type error) noexcept;

Parameters

overlappedconst OVERLAPPED&
The operation's OVERLAPPED; its Internal holds the final NTSTATUS.
errorType
The error reported for the completion; Success (0) if it succeeded.

Return value

Type: Type

Success if error is; otherwise the WSAE* code Winsock gives the operation's status (what WSAGetOverlappedResult would report), or error itself if the status is unknown here or no failure status is at hand.

Remarks

A completion port reports a failed operation as a Win32 code made from its NTSTATUS (ERROR_NETNAME_DELETED for a reset, say), while the same failure of a synchronous call is a WSAE* code (WSAECONNRESET). This maps the status back to the Winsock code without a socket at hand. A failure the issuer reported itself is a WSAE* code already and leaves no failure status in the OVERLAPPED, so it passes unchanged.

Succeeded

true for Success.

Syntax

static constexpr bool Succeeded(Type error) noexcept;

Parameters

errorType
The error code to test.

Return value

Type: bool

true if error is Success (0); otherwise false.

See also

Failed

Failed

true for anything but Success, including Pending.

Syntax

static constexpr bool Failed(Type error) noexcept;

Parameters

errorType
The error code to test.

Return value

Type: bool

true if error is not Success; otherwise false.

See also

Succeeded, IsPending

IsPending

true for Pending: an overlapped operation is in flight.

Syntax

static constexpr bool IsPending(Type error) noexcept;

Parameters

errorType
The error code to test.

Return value

Type: bool

true if error is Pending (WSA_IO_PENDING); otherwise false.

Types

Type

The underlying error type: int, as WSAGetLastError.

Syntax

using Type = int;

Fields

Success

Syntax

static constexpr Type Success = 0;

NotInitialized

Syntax

static constexpr Type NotInitialized = WSANOTINITIALISED;

BadDescriptor

Syntax

static constexpr Type BadDescriptor = WSAEBADF;

InvalidParameter

Syntax

static constexpr Type InvalidParameter = WSAEINVAL;

TooManyOpenFiles

Syntax

static constexpr Type TooManyOpenFiles = WSAEMFILE;

WouldBlock

Syntax

static constexpr Type WouldBlock = WSAEWOULDBLOCK;

InProgress

Syntax

static constexpr Type InProgress = WSAEINPROGRESS;

AlreadyInProgress

Syntax

static constexpr Type AlreadyInProgress = WSAEALREADY;

NotSocket

Syntax

static constexpr Type NotSocket = WSAENOTSOCK;

MessageSize

Syntax

static constexpr Type MessageSize = WSAEMSGSIZE;

ProtocolType

Syntax

static constexpr Type ProtocolType = WSAEPROTOTYPE;

ProtocolOption

Syntax

static constexpr Type ProtocolOption = WSAENOPROTOOPT;

OperationNotSupported

Syntax

static constexpr Type OperationNotSupported = WSAEOPNOTSUPP;

AddressFamilyNotSupported

Syntax

static constexpr Type AddressFamilyNotSupported = WSAEAFNOSUPPORT;

AddressInUse

Syntax

static constexpr Type AddressInUse = WSAEADDRINUSE;

AddressNotAvailable

Syntax

static constexpr Type AddressNotAvailable = WSAEADDRNOTAVAIL;

ConnectionAborted

Syntax

static constexpr Type ConnectionAborted = WSAECONNABORTED;

ConnectionReset

Syntax

static constexpr Type ConnectionReset = WSAECONNRESET;

NotConnected

Syntax

static constexpr Type NotConnected = WSAENOTCONN;

ConnectionRefused

Syntax

static constexpr Type ConnectionRefused = WSAECONNREFUSED;

Pending

WSA_IO_PENDING: an overlapped operation was started and completes later.

Syntax

static constexpr Type Pending = WSA_IO_PENDING;

Incomplete

WSA_IO_INCOMPLETE: the operation is still pending.

Syntax

static constexpr Type Incomplete = WSA_IO_INCOMPLETE;

Remarks

Returned by GetOverlappedResult without wait.

InvalidHandle

Syntax

static constexpr Type InvalidHandle = WSA_INVALID_HANDLE;

InvalidParameterW

WSA_INVALID_PARAMETER (ERROR_INVALID_PARAMETER).

Syntax

static constexpr Type InvalidParameterW = WSA_INVALID_PARAMETER;

Remarks

Not the same value as InvalidParameter (WSAEINVAL).

NotEnoughMemory

Syntax

static constexpr Type NotEnoughMemory = WSA_NOT_ENOUGH_MEMORY;

OperationAborted

WSA_OPERATION_ABORTED: the operation was cancelled or its socket closed.

Syntax

static constexpr Type OperationAborted = WSA_OPERATION_ABORTED;

TimedOut

WSAETIMEDOUT: the operation timed out.

Syntax

static constexpr Type TimedOut = WSAETIMEDOUT;

Remarks

Also returned by the AsyncIo::AsyncSocket waiting forms when their timeout expired.

Generated from ThinkMeta.ConcurrentTasks.API @ c7663c4 (2026-11-19).