windows/ws2_32

Windows Winsock2 declarations for subsystem startup, socket lifecycle, byte-order conversion, address resolution, overlapped I/O, and completion-port integration.


Startup and cleanup


Constants

Constant example

"windows/ws2_32" use
"control" use

{} () {} [
  AF_INET printStack _:;
  SOCK_STREAM printStack _:;
  INVALID_SOCKET printStack _:;
  WSAEWOULDBLOCK printStack _:;
  SD_BOTH printStack _:;
] "main" exportFunction

Expected Output During Compilation

2
1
18446744073709551615nx
10035
2

Declared schemas

Schema example

"windows/ws2_32" use
"control" use

{} () {} [
  WSABUF fieldCount printStack _:;
  sockaddr_in fieldCount printStack _:;
  sockaddr_in 2 fieldName printStack _:;
] "main" exportFunction

Expected Output During Compilation

2
4
"sin_addr"

Socket and address model


Arguments and results


Readiness, nonblocking, and AcceptEx


Overlapped I/O


Extension-function lookup

AcceptEx, ConnectEx, and GetAcceptExSockaddrs are not imported directly. Their identifiers and callback schemas are provided for lookup through WSAIoctl with SIO_GET_EXTENSION_FUNCTION_POINTER.


Imported functions


Signature examples

Printing imported names during compilation shows the exact imported signatures.

"windows/ws2_32" use
"control" use

{} Int32 {} [
  @WSAStartup printStack _:;
  @WSARecv printStack _:;
  @socket printStack _:;
  0
] "main" exportFunction

Expected Output During Compilation

{wVersionRequested: Nat16; lpWSAData: {wVersion: Nat16; wHighVersion: Nat16; iMaxSockets: Nat16; iMaxUdpDg: Nat16; lpVendorInfo: Nat8 Ref; szDescription: Nat8 257 array; szSystemStatus: Nat8 129 array;} Ref;} Int32 {convention: "";} codeRef
{s: Natx; lpBuffers: {len: Nat32; buf: Natx;} Ref; dwBufferCount: Nat32; lpNumberOfBytesRecvd: Nat32 Ref; lpFlags: Nat32 Ref; lpOverlapped: {Internal: Natx; InternalHigh: Natx; DUMMYUNIONNAME: Nat64; hEvent: Natx;} Ref; lpCompletionRoutine: {dwError: Nat32; cbTransferred: Nat32; lpOverlapped: {Internal: Natx; InternalHigh: Natx; DUMMYUNIONNAME: Nat64; hEvent: Natx;} Ref; dwFlags: Nat32;} () {convention: "";} codeRef;} Int32 {convention: "";} codeRef
{af: Int32; type: Int32; protocol: Int32;} Natx {convention: "";} codeRef

See also