Module:       WinSock2
Copyright:    Original Code is Copyright (c) 1995-2004 Functional Objects, Inc.
              All rights reserved.
License:      See License.txt in this distribution for details.
Warranty:     Distributed WITHOUT WARRANTY OF ANY KIND

// This file is automatically generated from "winsock2.h"; do not edit.

/* Winsock2.h -- definitions to be used with the WinSock 2 DLL and
 *               WinSock 2 applications.
 *
 * This header file corresponds to version 2.2.x of the WinSock API
 * specification.
 *
 * This file includes parts which are 
 * of the University of California.  All rights reserved.  The
 * Berkeley Software License Agreement specifies the terms and
 * conditions for redistribution.
 */ 
define inline-only constant $WINSOCK-VERSION            =
	MAKEWORD(2,2);
define inline constant <u-char> = <C-unsigned-char>;
define inline constant <u-short> = <C-unsigned-short>;
define inline constant <u-int> = <C-unsigned-int>;
define inline constant <u-long> = <C-both-unsigned-long>;
define inline-only constant $FD-SETSIZE                 =   64;

define C-struct <fd-set>
  sealed inline-only slot fd-count-value :: <u-int>;
  sealed inline-only array slot fd-array-array :: <C-SOCKET>,
	length: $FD-SETSIZE, address-getter: fd-array-value;
  pack: 4;
  pointer-type-name: <LPfd-set>;
  c-name: "struct fd_set";
end C-struct <fd-set>;

define inline-only C-function %-WSAFDIsSet
  parameter socket1    :: <C-SOCKET>;
  parameter lpfdset2   :: <LPfd-set>;
  result value :: <C-int>;
  c-name: "__WSAFDIsSet", c-modifiers: "__stdcall";
end;

define inline-only function FD-ISSET (fd, set);
  %-WSAFDIsSet(fd, pointer-cast(<LPFD-SET>, set))
end;

define C-struct <timeval>
  sealed inline-only slot tv-sec-value   :: <C-both-long>;
  sealed inline-only slot tv-usec-value  :: <C-both-long>;
  pointer-type-name: <LPTIMEVAL>;
end C-struct;

define inline-only function timerclear (tvp);
  tvp.tv-sec-value := tvp.tv-usec-value := 0
end;
define inline-only constant $IOCPARM-MASK               = #x7f;
define inline-only constant $IOC-VOID                   =
	as(<machine-word>, #x20000000);
define inline-only constant $IOC-OUT                    =
	as(<machine-word>, #x40000000);
define inline-only constant $IOC-IN                     =
	as(<machine-word>, #x80000000);
define inline-only constant $IOC-INOUT                  =
	%logior($IOC-IN, $IOC-OUT);

define inline-only function %IOR (x,y,t);
  %logior($IOC-OUT, ash(logand(size-of(t), $IOCPARM-MASK), 16), ash(x,8), y)
end;

define inline-only function %IOW (x,y,t);
  %logior($IOC-IN, ash(logand(size-of(t), $IOCPARM-MASK), 16), ash(x,8), y)
end;
define inline-only constant $FIONREAD                   =
	%IOR(as(<integer>, 'f'), 127, <u-long>);
define inline-only constant $FIONBIO                    =
	%IOW(as(<integer>, 'f'), 126, <u-long>);
define inline-only constant $FIOASYNC                   =
	%IOW(as(<integer>, 'f'), 125, <u-long>);
define inline-only constant $SIOCSHIWAT                 =
	%IOW(as(<integer>, 's'), 0, <u-long>);
define inline-only constant $SIOCGHIWAT                 =
	%IOR(as(<integer>, 's'), 1, <u-long>);
define inline-only constant $SIOCSLOWAT                 =
	%IOW(as(<integer>, 's'), 2, <u-long>);
define inline-only constant $SIOCGLOWAT                 =
	%IOR(as(<integer>, 's'), 3, <u-long>);
define inline-only constant $SIOCATMARK                 =
	%IOR(as(<integer>, 's'), 7, <u-long>);

define C-struct <hostent>
  sealed inline-only slot h-name-value   :: <C-char*>;
  sealed inline-only slot h-aliases-value :: <C-char**>;
  sealed inline-only slot h-addrtype-value :: <C-short>;
  sealed inline-only slot h-length-value :: <C-short>;
  sealed inline-only slot h-addr-list-value :: <C-char**>;
  pointer-type-name: <LPHOSTENT>;
end C-struct;

define C-struct <netent>
  sealed inline-only slot n-name-value   :: <C-char*>;
  sealed inline-only slot n-aliases-value :: <C-char**>;
  sealed inline-only slot n-addrtype-value :: <C-short>;
  sealed inline-only slot n-net-value    :: <u-long>;
  pointer-type-name: <LPNETENT>;
end C-struct;

define C-struct <servent>
  sealed inline-only slot s-name-value   :: <C-char*>;
  sealed inline-only slot s-aliases-value :: <C-char**>;
  sealed inline-only slot s-port-value   :: <C-short>;
  sealed inline-only slot s-proto-value  :: <C-char*>;
  pointer-type-name: <LPSERVENT>;
end C-struct;

define C-struct <protoent>
  sealed inline-only slot p-name-value   :: <C-char*>;
  sealed inline-only slot p-aliases-value :: <C-char**>;
  sealed inline-only slot p-proto-value  :: <C-short>;
  pointer-type-name: <LPPROTOENT>;
end C-struct;
define inline-only constant $IPPROTO-IP                 =    0;
define inline-only constant $IPPROTO-ICMP               =    1;
define inline-only constant $IPPROTO-IGMP               =    2;
define inline-only constant $IPPROTO-GGP                =    3;
define inline-only constant $IPPROTO-TCP                =    6;
define inline-only constant $IPPROTO-PUP                =   12;
define inline-only constant $IPPROTO-UDP                =   17;
define inline-only constant $IPPROTO-IDP                =   22;
define inline-only constant $IPPROTO-ND                 =   77;
define inline-only constant $IPPROTO-RAW                =  255;
define inline-only constant $IPPROTO-MAX                =  256;
define inline-only constant $IPPORT-ECHO                =    7;
define inline-only constant $IPPORT-DISCARD             =    9;
define inline-only constant $IPPORT-SYSTAT              =   11;
define inline-only constant $IPPORT-DAYTIME             =   13;
define inline-only constant $IPPORT-NETSTAT             =   15;
define inline-only constant $IPPORT-FTP                 =   21;
define inline-only constant $IPPORT-TELNET              =   23;
define inline-only constant $IPPORT-SMTP                =   25;
define inline-only constant $IPPORT-TIMESERVER          =   37;
define inline-only constant $IPPORT-NAMESERVER          =   42;
define inline-only constant $IPPORT-WHOIS               =   43;
define inline-only constant $IPPORT-MTP                 =   57;
define inline-only constant $IPPORT-TFTP                =   69;
define inline-only constant $IPPORT-RJE                 =   77;
define inline-only constant $IPPORT-FINGER              =   79;
define inline-only constant $IPPORT-TTYLINK             =   87;
define inline-only constant $IPPORT-SUPDUP              =   95;
define inline-only constant $IPPORT-EXECSERVER          =  512;
define inline-only constant $IPPORT-LOGINSERVER         =  513;
define inline-only constant $IPPORT-CMDSERVER           =  514;
define inline-only constant $IPPORT-EFSSERVER           =  520;
define inline-only constant $IPPORT-BIFFUDP             =  512;
define inline-only constant $IPPORT-WHOSERVER           =  513;
define inline-only constant $IPPORT-ROUTESERVER         =  520;
define inline-only constant $IPPORT-RESERVED            = 1024;
define inline-only constant $IMPLINK-IP                 =  155;
define inline-only constant $IMPLINK-LOWEXPER           =  156;
define inline-only constant $IMPLINK-HIGHEXPER          =  158;
define constant <in-addr> = <C-raw-unsigned-long>;

define inline-only function IN-CLASSA (i);
  (%logand(i, as(<machine-word>, #x80000000)) = 0)
end;
define inline-only constant $IN-CLASSA-NET              =
	as(<machine-word>, #xff000000);
define inline-only constant $IN-CLASSA-NSHIFT           =   24;
define inline-only constant $IN-CLASSA-HOST             = #x00ffffff;
define inline-only constant $IN-CLASSA-MAX              =  128;

define inline-only function IN-CLASSB (i);
  (%logand(i, as(<machine-word>, #xc0000000)) = as(<machine-word>, #x80000000))
end;
define inline-only constant $IN-CLASSB-NET              =
	as(<machine-word>, #xffff0000);
define inline-only constant $IN-CLASSB-NSHIFT           =   16;
define inline-only constant $IN-CLASSB-HOST             = #x0000ffff;
define inline-only constant $IN-CLASSB-MAX              = 65536;

define inline-only function IN-CLASSC (i);
  (%logand(i, as(<machine-word>, #xe0000000)) = as(<machine-word>, #xc0000000))
end;
define inline-only constant $IN-CLASSC-NET              =
	as(<machine-word>, #xffffff00);
define inline-only constant $IN-CLASSC-NSHIFT           =    8;
define inline-only constant $IN-CLASSC-HOST             = #x000000ff;

define inline-only function IN-CLASSD (i);
  (%logand(i, as(<machine-word>, #xf0000000)) = as(<machine-word>, #xe0000000))
end;
define inline-only constant $IN-CLASSD-NET              =
	as(<machine-word>, #xf0000000);
define inline-only constant $IN-CLASSD-NSHIFT           =   28;
define inline-only constant $IN-CLASSD-HOST             = #x0fffffff;

define inline-only function IN-MULTICAST (i);
  IN-CLASSD(i)
end;
define inline-only constant $INADDR-ANY                 = #x00000000;
define inline-only constant $INADDR-LOOPBACK            =
	as(<machine-word>, #x7f000001);
define inline-only constant $INADDR-BROADCAST           = $FFFFFFFF;
define inline-only constant $INADDR-NONE                = $FFFFFFFF;

define C-struct <sockaddr-in>
  sealed inline-only slot sin-family-value :: <C-short>;
  sealed inline-only slot sin-port-value :: <u-short>;
  sealed inline-only slot sin-addr-value :: <in-addr>;
  sealed inline-only array slot sin-zero-array :: <C-char>,
	length: 8, address-getter: sin-zero-value;
  pointer-type-name: <LPSOCKADDR-IN>;
end C-struct;
define inline-only constant $WSADESCRIPTION-LEN         =  256;
define inline-only constant $WSASYS-STATUS-LEN          =  128;

define C-struct <WSADATA>
  sealed inline-only slot wVersion-value :: <WORD>;
  sealed inline-only slot wHighVersion-value :: <WORD>;
  sealed inline-only array slot szDescription-array :: <C-char>,
	length: $WSADESCRIPTION-LEN + 1,
	address-getter: szDescription-value;
  sealed inline-only array slot szSystemStatus-array :: <C-char>,
	length: $WSASYS-STATUS-LEN + 1,
	address-getter: szSystemStatus-value;
  sealed inline-only slot iMaxSockets-value :: <C-unsigned-short>;
  sealed inline-only slot iMaxUdpDg-value :: <C-unsigned-short>;
  sealed inline-only slot lpVendorInfo-value :: <C-char*>;
  pack: 4;
  pointer-type-name: <LPWSADATA>;
  c-name: "struct WSAData";
end C-struct <WSADATA>;
define inline-only constant $INVALID-SOCKET             = lognot(0);
define inline-only constant $SOCKET-ERROR               =   -1;
define inline-only constant $FROM-PROTOCOL-INFO         =   -1;
define inline-only constant $SOCK-STREAM                =    1;
define inline-only constant $SOCK-DGRAM                 =    2;
define inline-only constant $SOCK-RAW                   =    3;
define inline-only constant $SOCK-RDM                   =    4;
define inline-only constant $SOCK-SEQPACKET             =    5;
define inline-only constant $SO-DEBUG                   = #x0001;
define inline-only constant $SO-ACCEPTCONN              = #x0002;
define inline-only constant $SO-REUSEADDR               = #x0004;
define inline-only constant $SO-KEEPALIVE               = #x0008;
define inline-only constant $SO-DONTROUTE               = #x0010;
define inline-only constant $SO-BROADCAST               = #x0020;
define inline-only constant $SO-USELOOPBACK             = #x0040;
define inline-only constant $SO-LINGER                  = #x0080;
define inline-only constant $SO-OOBINLINE               = #x0100;
define inline-only constant $SO-DONTLINGER              =
	lognot($SO-LINGER);
define inline-only constant $SO-SNDBUF                  = #x1001;
define inline-only constant $SO-RCVBUF                  = #x1002;
define inline-only constant $SO-SNDLOWAT                = #x1003;
define inline-only constant $SO-RCVLOWAT                = #x1004;
define inline-only constant $SO-SNDTIMEO                = #x1005;
define inline-only constant $SO-RCVTIMEO                = #x1006;
define inline-only constant $SO-ERROR                   = #x1007;
define inline-only constant $SO-TYPE                    = #x1008;
define inline-only constant $SO-GROUP-ID                = #x2001;
define inline-only constant $SO-GROUP-PRIORITY          = #x2002;
define inline-only constant $SO-MAX-MSG-SIZE            = #x2003;
define inline-only constant $SO-PROTOCOL-INFOA          = #x2004;
define inline-only constant $SO-PROTOCOL-INFOW          = #x2005;
define inline-only constant $PVD-CONFIG                 = #x3001;
define inline-only constant $TCP-NODELAY                = #x0001;
define inline-only constant $AF-UNSPEC                  =    0;
define inline-only constant $AF-UNIX                    =    1;
define inline-only constant $AF-INET                    =    2;
define inline-only constant $AF-IMPLINK                 =    3;
define inline-only constant $AF-PUP                     =    4;
define inline-only constant $AF-CHAOS                   =    5;
define inline-only constant $AF-NS                      =    6;
define inline-only constant $AF-ISO                     =    7;
define inline-only constant $AF-ECMA                    =    8;
define inline-only constant $AF-DATAKIT                 =    9;
define inline-only constant $AF-CCITT                   =   10;
define inline-only constant $AF-SNA                     =   11;
define inline-only constant $AF-DECnet                  =   12;
define inline-only constant $AF-DLI                     =   13;
define inline-only constant $AF-LAT                     =   14;
define inline-only constant $AF-HYLINK                  =   15;
define inline-only constant $AF-APPLETALK               =   16;
define inline-only constant $AF-NETBIOS                 =   17;
define inline-only constant $AF-VOICEVIEW               =   18;
define inline-only constant $AF-FIREFOX                 =   19;
define inline-only constant $AF-UNKNOWN1                =   20;
define inline-only constant $AF-BAN                     =   21;
define inline-only constant $AF-ATM                     =   22;
define inline-only constant $AF-INET6                   =   23;
define inline-only constant $AF-CLUSTER                 =   24;
define inline-only constant $AF-12844                   =   25;
define inline-only constant $AF-MAX                     =   26;

define C-struct <sockaddr>
  sealed inline-only slot sa-family-value :: <u-short>;
  sealed inline-only array slot sa-data-array :: <C-unsigned-char>,
	length: 14, address-getter: sa-data-value;
  pointer-type-name: <LPSOCKADDR>;
end C-struct;

define C-struct <sockproto>
  sealed inline-only slot sp-family-value :: <u-short>;
  sealed inline-only slot sp-protocol-value :: <u-short>;
  pointer-type-name: <LPSOCKPROTO>;
end C-struct;

define C-struct <linger>
  sealed inline-only slot l-onoff-value  :: <u-short>;
  sealed inline-only slot l-linger-value :: <u-short>;
  pointer-type-name: <LPLINGER>;
end C-struct;
define inline-only constant $SOL-SOCKET                 = #xffff;
define inline-only constant $SOMAXCONN                  =
	as(<machine-word>, #x7fffffff);
define inline-only constant $MSG-OOB                    =  #x1;
define inline-only constant $MSG-PEEK                   =  #x2;
define inline-only constant $MSG-DONTROUTE              =  #x4;
define inline-only constant $MSG-PARTIAL                = #x8000;
define inline-only constant $MSG-INTERRUPT              = #x10;
define inline-only constant $MSG-MAXIOVLEN              =   16;
define inline-only constant $MAXGETHOSTSTRUCT           = 1024;
define inline-only constant $FD-READ-BIT                =    0;
define inline-only constant $FD-READ                    =
	ash(1,$FD-READ-BIT);
define inline-only constant $FD-WRITE-BIT               =    1;
define inline-only constant $FD-WRITE                   =
	ash(1,$FD-WRITE-BIT);
define inline-only constant $FD-OOB-BIT                 =    2;
define inline-only constant $FD-OOB                     =
	ash(1,$FD-OOB-BIT);
define inline-only constant $FD-ACCEPT-BIT              =    3;
define inline-only constant $FD-ACCEPT                  =
	ash(1,$FD-ACCEPT-BIT);
define inline-only constant $FD-CONNECT-BIT             =    4;
define inline-only constant $FD-CONNECT                 =
	ash(1,$FD-CONNECT-BIT);
define inline-only constant $FD-CLOSE-BIT               =    5;
define inline-only constant $FD-CLOSE                   =
	ash(1,$FD-CLOSE-BIT);
define inline-only constant $FD-QOS-BIT                 =    6;
define inline-only constant $FD-QOS                     =
	ash(1,$FD-QOS-BIT);
define inline-only constant $FD-GROUP-QOS-BIT           =    7;
define inline-only constant $FD-GROUP-QOS               =
	ash(1,$FD-GROUP-QOS-BIT);
define inline-only constant $FD-ROUTING-INTERFACE-CHANGE-BIT =    8;
define inline-only constant $FD-ROUTING-INTERFACE-CHANGE =
	ash(1,$FD-ROUTING-INTERFACE-CHANGE-BIT);
define inline-only constant $FD-ADDRESS-LIST-CHANGE-BIT =    9;
define inline-only constant $FD-ADDRESS-LIST-CHANGE     =
	ash(1,$FD-ADDRESS-LIST-CHANGE-BIT);
define inline-only constant $FD-MAX-EVENTS              =   10;
define inline-only constant $WSABASEERR                 = 10000;
define inline-only constant $WSAEINTR                   =
	$WSABASEERR + 4;
define inline-only constant $WSAEBADF                   =
	$WSABASEERR + 9;
define inline-only constant $WSAEACCES                  =
	$WSABASEERR + 13;
define inline-only constant $WSAEFAULT                  =
	$WSABASEERR + 14;
define inline-only constant $WSAEINVAL                  =
	$WSABASEERR + 22;
define inline-only constant $WSAEMFILE                  =
	$WSABASEERR + 24;
define inline-only constant $WSAEWOULDBLOCK             =
	$WSABASEERR + 35;
define inline-only constant $WSAEINPROGRESS             =
	$WSABASEERR + 36;
define inline-only constant $WSAEALREADY                =
	$WSABASEERR + 37;
define inline-only constant $WSAENOTSOCK                =
	$WSABASEERR + 38;
define inline-only constant $WSAEDESTADDRREQ            =
	$WSABASEERR + 39;
define inline-only constant $WSAEMSGSIZE                =
	$WSABASEERR + 40;
define inline-only constant $WSAEPROTOTYPE              =
	$WSABASEERR + 41;
define inline-only constant $WSAENOPROTOOPT             =
	$WSABASEERR + 42;
define inline-only constant $WSAEPROTONOSUPPORT         =
	$WSABASEERR + 43;
define inline-only constant $WSAESOCKTNOSUPPORT         =
	$WSABASEERR + 44;
define inline-only constant $WSAEOPNOTSUPP              =
	$WSABASEERR + 45;
define inline-only constant $WSAEPFNOSUPPORT            =
	$WSABASEERR + 46;
define inline-only constant $WSAEAFNOSUPPORT            =
	$WSABASEERR + 47;
define inline-only constant $WSAEADDRINUSE              =
	$WSABASEERR + 48;
define inline-only constant $WSAEADDRNOTAVAIL           =
	$WSABASEERR + 49;
define inline-only constant $WSAENETDOWN                =
	$WSABASEERR + 50;
define inline-only constant $WSAENETUNREACH             =
	$WSABASEERR + 51;
define inline-only constant $WSAENETRESET               =
	$WSABASEERR + 52;
define inline-only constant $WSAECONNABORTED            =
	$WSABASEERR + 53;
define inline-only constant $WSAECONNRESET              =
	$WSABASEERR + 54;
define inline-only constant $WSAENOBUFS                 =
	$WSABASEERR + 55;
define inline-only constant $WSAEISCONN                 =
	$WSABASEERR + 56;
define inline-only constant $WSAENOTCONN                =
	$WSABASEERR + 57;
define inline-only constant $WSAESHUTDOWN               =
	$WSABASEERR + 58;
define inline-only constant $WSAETOOMANYREFS            =
	$WSABASEERR + 59;
define inline-only constant $WSAETIMEDOUT               =
	$WSABASEERR + 60;
define inline-only constant $WSAECONNREFUSED            =
	$WSABASEERR + 61;
define inline-only constant $WSAELOOP                   =
	$WSABASEERR + 62;
define inline-only constant $WSAENAMETOOLONG            =
	$WSABASEERR + 63;
define inline-only constant $WSAEHOSTDOWN               =
	$WSABASEERR + 64;
define inline-only constant $WSAEHOSTUNREACH            =
	$WSABASEERR + 65;
define inline-only constant $WSAENOTEMPTY               =
	$WSABASEERR + 66;
define inline-only constant $WSAEPROCLIM                =
	$WSABASEERR + 67;
define inline-only constant $WSAEUSERS                  =
	$WSABASEERR + 68;
define inline-only constant $WSAEDQUOT                  =
	$WSABASEERR + 69;
define inline-only constant $WSAESTALE                  =
	$WSABASEERR + 70;
define inline-only constant $WSAEREMOTE                 =
	$WSABASEERR + 71;
define inline-only constant $WSASYSNOTREADY             =
	$WSABASEERR + 91;
define inline-only constant $WSAVERNOTSUPPORTED         =
	$WSABASEERR + 92;
define inline-only constant $WSANOTINITIALISED          =
	$WSABASEERR + 93;
define inline-only constant $WSAEDISCON                 =
	$WSABASEERR + 101;
define inline-only constant $WSAENOMORE                 =
	$WSABASEERR + 102;
define inline-only constant $WSAECANCELLED              =
	$WSABASEERR + 103;
define inline-only constant $WSAEINVALIDPROCTABLE       =
	$WSABASEERR + 104;
define inline-only constant $WSAEINVALIDPROVIDER        =
	$WSABASEERR + 105;
define inline-only constant $WSAEPROVIDERFAILEDINIT     =
	$WSABASEERR + 106;
define inline-only constant $WSASYSCALLFAILURE          =
	$WSABASEERR + 107;
define inline-only constant $WSASERVICE-NOT-FOUND       =
	$WSABASEERR + 108;
define inline-only constant $WSATYPE-NOT-FOUND          =
	$WSABASEERR + 109;
define inline-only constant $WSA-E-NO-MORE              =
	$WSABASEERR + 110;
define inline-only constant $WSA-E-CANCELLED            =
	$WSABASEERR + 111;
define inline-only constant $WSAEREFUSED                =
	$WSABASEERR + 112;
define inline-only constant $WSAHOST-NOT-FOUND          =
	$WSABASEERR + 1001;
define inline-only constant $WSATRY-AGAIN               =
	$WSABASEERR + 1002;
define inline-only constant $WSANO-RECOVERY             =
	$WSABASEERR + 1003;
define inline-only constant $WSANO-DATA                 =
	$WSABASEERR + 1004;
define inline-only constant $WSA-QOS-RECEIVERS          =
	$WSABASEERR + 1005;
define inline-only constant $WSA-QOS-SENDERS            =
	$WSABASEERR + 1006;
define inline-only constant $WSA-QOS-NO-SENDERS         =
	$WSABASEERR + 1007;
define inline-only constant $WSA-QOS-NO-RECEIVERS       =
	$WSABASEERR + 1008;
define inline-only constant $WSA-QOS-REQUEST-CONFIRMED  =
	$WSABASEERR + 1009;
define inline-only constant $WSA-QOS-ADMISSION-FAILURE  =
	$WSABASEERR + 1010;
define inline-only constant $WSA-QOS-POLICY-FAILURE     =
	$WSABASEERR + 1011;
define inline-only constant $WSA-QOS-BAD-STYLE          =
	$WSABASEERR + 1012;
define inline-only constant $WSA-QOS-BAD-OBJECT         =
	$WSABASEERR + 1013;
define inline-only constant $WSA-QOS-TRAFFIC-CTRL-ERROR =
	$WSABASEERR + 1014;
define inline-only constant $WSA-QOS-GENERIC-ERROR      =
	$WSABASEERR + 1015;
define constant <WSAEVENT> = <HANDLE>;
define constant <LPWSAEVENT> = <LPHANDLE>;
define constant <WSAOVERLAPPED> = <OVERLAPPED>;
define C-pointer-type <LPWSAOVERLAPPED> => <OVERLAPPED>;
define inline-only constant $WSA-IO-PENDING             =
	$ERROR-IO-PENDING;
define inline-only constant $WSA-IO-INCOMPLETE          =
	$ERROR-IO-INCOMPLETE;
define inline-only constant $WSA-INVALID-HANDLE         =
	$ERROR-INVALID-HANDLE;
define inline-only constant $WSA-INVALID-PARAMETER      =
	$ERROR-INVALID-PARAMETER;
define inline-only constant $WSA-NOT-ENOUGH-MEMORY      =
	$ERROR-NOT-ENOUGH-MEMORY;
define inline-only constant $WSA-OPERATION-ABORTED      =
	$ERROR-OPERATION-ABORTED;
define inline-only constant $WSA-INVALID-EVENT          =
	$NULL-HANDLE;
define inline-only constant $WSA-MAXIMUM-WAIT-EVENTS    =
	$MAXIMUM-WAIT-OBJECTS;
define inline-only constant $WSA-WAIT-FAILED            =   -1;
define inline-only constant $WSA-WAIT-EVENT-0           =
	$WAIT-OBJECT-0;
define inline-only constant $WSA-WAIT-IO-COMPLETION     =
	$WAIT-IO-COMPLETION;
define inline-only constant $WSA-WAIT-TIMEOUT           =
	$WAIT-TIMEOUT;
define inline-only constant $WSA-INFINITE               = $FFFFFFFF;

define C-struct <WSABUF>
  sealed inline-only slot len-value      :: <u-long>;
  sealed inline-only slot buf-value      :: <C-char*>;
  pack: 4;
  pointer-type-name: <LPWSABUF>;
  c-name: "struct _WSABUF";
end C-struct <WSABUF>;

define C-struct <QOS>
  sealed inline-only slot SendingFlowspec-value :: <FLOWSPEC>;
  sealed inline-only slot ReceivingFlowspec-value :: <FLOWSPEC>;
  sealed inline-only slot ProviderSpecific-value :: <WSABUF>;
  pack: 4;
  pointer-type-name: <LPQOS>;
  c-name: "struct _QualityOfService";
end C-struct <QOS>;
define inline-only constant $CF-ACCEPT                  = #x0000;
define inline-only constant $CF-REJECT                  = #x0001;
define inline-only constant $CF-DEFER                   = #x0002;
define inline-only constant $SD-RECEIVE                 = #x00;
define inline-only constant $SD-SEND                    = #x01;
define inline-only constant $SD-BOTH                    = #x02;
define inline constant <GROUP> = <C-unsigned-int>;
define inline-only constant $SG-UNCONSTRAINED-GROUP     = #x01;
define inline-only constant $SG-CONSTRAINED-GROUP       = #x02;

define C-struct <WSANETWORKEVENTS>
  sealed inline-only slot lNetworkEvents-value :: <C-both-long>;
  sealed inline-only array slot iErrorCode-array :: <C-int>,
	length: $FD-MAX-EVENTS, address-getter: iErrorCode-value;
  pack: 4;
  pointer-type-name: <LPWSANETWORKEVENTS>;
  c-name: "struct _WSANETWORKEVENTS";
end C-struct <WSANETWORKEVENTS>;

define C-struct <GUID>
  sealed inline-only slot Data1-value    :: <C-both-unsigned-long>;
  sealed inline-only slot Data2-value    :: <C-unsigned-short>;
  sealed inline-only slot Data3-value    :: <C-unsigned-short>;
  array slot Data4-array :: <C-unsigned-char>, length: 8,
	address-getter: Data4-value;
  pack: 4;
  pointer-type-name: <LPGUID>;
  c-name: "struct _GUID";
end C-struct <GUID>;
define inline-only constant $MAX-PROTOCOL-CHAIN         =    7;
define inline-only constant $BASE-PROTOCOL              =    1;
define inline-only constant $LAYERED-PROTOCOL           =    0;

define C-struct <WSAPROTOCOLCHAIN>
  sealed inline-only slot ChainLen-value :: <C-int>;
  sealed inline-only array slot ChainEntries-array :: <DWORD>,
	length: $MAX-PROTOCOL-CHAIN, address-getter: ChainEntries-value;
  pack: 4;
  pointer-type-name: <LPWSAPROTOCOLCHAIN>;
  c-name: "struct _WSAPROTOCOLCHAIN";
end C-struct <WSAPROTOCOLCHAIN>;
define inline-only constant $WSAPROTOCOL-LEN            =  255;

define C-struct <WSAPROTOCOL-INFOA>
  sealed inline-only slot dwServiceFlags1-value :: <DWORD>;
  sealed inline-only slot dwServiceFlags2-value :: <DWORD>;
  sealed inline-only slot dwServiceFlags3-value :: <DWORD>;
  sealed inline-only slot dwServiceFlags4-value :: <DWORD>;
  sealed inline-only slot dwProviderFlags-value :: <DWORD>;
  sealed inline-only slot ProviderId-value :: <GUID>;
  sealed inline-only slot dwCatalogEntryId-value :: <DWORD>;
  sealed inline-only slot ProtocolChain-value :: <WSAPROTOCOLCHAIN>;
  sealed inline-only slot iVersion-value :: <C-int>;
  sealed inline-only slot iAddressFamily-value :: <C-int>;
  sealed inline-only slot iMaxSockAddr-value :: <C-int>;
  sealed inline-only slot iMinSockAddr-value :: <C-int>;
  sealed inline-only slot iSocketType-value :: <C-int>;
  sealed inline-only slot iProtocol-value :: <C-int>;
  sealed inline-only slot iProtocolMaxOffset-value :: <C-int>;
  sealed inline-only slot iNetworkByteOrder-value :: <C-int>;
  sealed inline-only slot iSecurityScheme-value :: <C-int>;
  sealed inline-only slot dwMessageSize-value :: <DWORD>;
  sealed inline-only slot dwProviderReserved :: <DWORD>;
  sealed inline-only array slot szProtocol-array :: <CHAR>,
	length: $WSAPROTOCOL-LEN + 1, address-getter: szProtocol-value;
  pack: 4;
  pointer-type-name: <LPWSAPROTOCOL-INFOA>;
  c-name: "struct _WSAPROTOCOL_INFOA";
end C-struct <WSAPROTOCOL-INFOA>;

define C-struct <WSAPROTOCOL-INFOW>
  sealed inline-only slot dwServiceFlags1-value :: <DWORD>;
  sealed inline-only slot dwServiceFlags2-value :: <DWORD>;
  sealed inline-only slot dwServiceFlags3-value :: <DWORD>;
  sealed inline-only slot dwServiceFlags4-value :: <DWORD>;
  sealed inline-only slot dwProviderFlags-value :: <DWORD>;
  sealed inline-only slot ProviderId-value :: <GUID>;
  sealed inline-only slot dwCatalogEntryId-value :: <DWORD>;
  sealed inline-only slot ProtocolChain-value :: <WSAPROTOCOLCHAIN>;
  sealed inline-only slot iVersion-value :: <C-int>;
  sealed inline-only slot iAddressFamily-value :: <C-int>;
  sealed inline-only slot iMaxSockAddr-value :: <C-int>;
  sealed inline-only slot iMinSockAddr-value :: <C-int>;
  sealed inline-only slot iSocketType-value :: <C-int>;
  sealed inline-only slot iProtocol-value :: <C-int>;
  sealed inline-only slot iProtocolMaxOffset-value :: <C-int>;
  sealed inline-only slot iNetworkByteOrder-value :: <C-int>;
  sealed inline-only slot iSecurityScheme-value :: <C-int>;
  sealed inline-only slot dwMessageSize-value :: <DWORD>;
  sealed inline-only slot dwProviderReserved :: <DWORD>;
  sealed inline-only array slot szProtocol-array :: <WCHAR>,
	length: $WSAPROTOCOL-LEN + 1, address-getter: szProtocol-value;
  pack: 4;
  pointer-type-name: <LPWSAPROTOCOL-INFOW>;
  c-name: "struct _WSAPROTOCOL_INFOW";
end C-struct <WSAPROTOCOL-INFOW>;
define inline constant <WSAPROTOCOL-INFO> = <WSAPROTOCOL-INFOA>;
define inline constant <LPWSAPROTOCOL-INFO> = <LPWSAPROTOCOL-INFOA>;
define inline-only constant $PFL-MULTIPLE-PROTO-ENTRIES = #x00000001;
define inline-only constant $PFL-RECOMMENDED-PROTO-ENTRY =
	#x00000002;
define inline-only constant $PFL-HIDDEN                 = #x00000004;
define inline-only constant $PFL-MATCHES-PROTOCOL-ZERO  = #x00000008;
define inline-only constant $XP1-CONNECTIONLESS         = #x00000001;
define inline-only constant $XP1-GUARANTEED-DELIVERY    = #x00000002;
define inline-only constant $XP1-GUARANTEED-ORDER       = #x00000004;
define inline-only constant $XP1-MESSAGE-ORIENTED       = #x00000008;
define inline-only constant $XP1-PSEUDO-STREAM          = #x00000010;
define inline-only constant $XP1-GRACEFUL-CLOSE         = #x00000020;
define inline-only constant $XP1-EXPEDITED-DATA         = #x00000040;
define inline-only constant $XP1-CONNECT-DATA           = #x00000080;
define inline-only constant $XP1-DISCONNECT-DATA        = #x00000100;
define inline-only constant $XP1-SUPPORT-BROADCAST      = #x00000200;
define inline-only constant $XP1-SUPPORT-MULTIPOINT     = #x00000400;
define inline-only constant $XP1-MULTIPOINT-CONTROL-PLANE =
	#x00000800;
define inline-only constant $XP1-MULTIPOINT-DATA-PLANE  = #x00001000;
define inline-only constant $XP1-QOS-SUPPORTED          = #x00002000;
define inline-only constant $XP1-INTERRUPT              = #x00004000;
define inline-only constant $XP1-UNI-SEND               = #x00008000;
define inline-only constant $XP1-UNI-RECV               = #x00010000;
define inline-only constant $XP1-IFS-HANDLES            = #x00020000;
define inline-only constant $XP1-PARTIAL-MESSAGE        = #x00040000;
define inline-only constant $BIGENDIAN                  = #x0000;
define inline-only constant $LITTLEENDIAN               = #x0001;
define inline-only constant $SECURITY-PROTOCOL-NONE     = #x0000;
define inline-only constant $JL-SENDER-ONLY             = #x01;
define inline-only constant $JL-RECEIVER-ONLY           = #x02;
define inline-only constant $JL-BOTH                    = #x04;
define inline-only constant $WSA-FLAG-OVERLAPPED        = #x01;
define inline-only constant $WSA-FLAG-MULTIPOINT-C-ROOT = #x02;
define inline-only constant $WSA-FLAG-MULTIPOINT-C-LEAF = #x04;
define inline-only constant $WSA-FLAG-MULTIPOINT-D-ROOT = #x08;
define inline-only constant $WSA-FLAG-MULTIPOINT-D-LEAF = #x10;
define inline-only constant $IOC-UNIX                   = #x00000000;
define inline-only constant $IOC-WS2                    = #x08000000;
define inline-only constant $IOC-PROTOCOL               =
	as(<machine-word>, #x10000000);
define inline-only constant $IOC-VENDOR                 =
	as(<machine-word>, #x18000000);

define inline-only function %WSAIO (x,y);
  %logior($IOC-VOID, x, y)
end;

define inline-only function %WSAIOR (x,y);
  %logior($IOC-OUT, x, y)
end;

define inline-only function %WSAIOW (x,y);
  %logior($IOC-IN, x, y)
end;

define inline-only function %WSAIORW (x,y);
  %logior($IOC-INOUT, x, y)
end;
define inline-only constant $SIO-ASSOCIATE-HANDLE       =
	%WSAIOW($IOC-WS2,1);
define inline-only constant $SIO-ENABLE-CIRCULAR-QUEUEING =
	%WSAIO($IOC-WS2,2);
define inline-only constant $SIO-FIND-ROUTE             =
	%WSAIOR($IOC-WS2,3);
define inline-only constant $SIO-FLUSH                  =
	%WSAIO($IOC-WS2,4);
define inline-only constant $SIO-GET-BROADCAST-ADDRESS  =
	%WSAIOR($IOC-WS2,5);
define inline-only constant $SIO-GET-EXTENSION-FUNCTION-POINTER =
	%WSAIORW($IOC-WS2,6);
define inline-only constant $SIO-GET-QOS                =
	%WSAIORW($IOC-WS2,7);
define inline-only constant $SIO-GET-GROUP-QOS          =
	%WSAIORW($IOC-WS2,8);
define inline-only constant $SIO-MULTIPOINT-LOOPBACK    =
	%WSAIOW($IOC-WS2,9);
define inline-only constant $SIO-MULTICAST-SCOPE        =
	%WSAIOW($IOC-WS2,10);
define inline-only constant $SIO-SET-QOS                =
	%WSAIOW($IOC-WS2,11);
define inline-only constant $SIO-SET-GROUP-QOS          =
	%WSAIOW($IOC-WS2,12);
define inline-only constant $SIO-TRANSLATE-HANDLE       =
	%WSAIORW($IOC-WS2,13);
define inline-only constant $SIO-ROUTING-INTERFACE-QUERY =
	%WSAIORW($IOC-WS2,20);
define inline-only constant $SIO-ROUTING-INTERFACE-CHANGE =
	%WSAIOW($IOC-WS2,21);
define inline-only constant $SIO-ADDRESS-LIST-QUERY     =
	%WSAIOR($IOC-WS2,22);
define inline-only constant $SIO-ADDRESS-LIST-CHANGE    =
	%WSAIO($IOC-WS2,23);
define inline-only constant $TH-NETDEV                  = #x00000001;
define inline-only constant $TH-TAPI                    = #x00000002;

define C-struct <BLOB>
  sealed inline-only slot cbSize-value   :: <ULONG>;
  sealed inline-only slot pBlobData-value :: <C-BYTE*>;
  pack: 4;
  pointer-type-name: <LPBLOB>;
  c-name: "struct _BLOB";
end C-struct <BLOB>;
define inline-only constant $SERVICE-MULTIPLE           = #x00000001;
define inline-only constant $NS-ALL                     =    0;
define inline-only constant $NS-SAP                     =    1;
define inline-only constant $NS-NDS                     =    2;
define inline-only constant $NS-PEER-BROWSE             =    3;
define inline-only constant $NS-TCPIP-LOCAL             =   10;
define inline-only constant $NS-TCPIP-HOSTS             =   11;
define inline-only constant $NS-DNS                     =   12;
define inline-only constant $NS-NETBT                   =   13;
define inline-only constant $NS-WINS                    =   14;
define inline-only constant $NS-NBP                     =   20;
define inline-only constant $NS-MS                      =   30;
define inline-only constant $NS-STDA                    =   31;
define inline-only constant $NS-NTDS                    =   32;
define inline-only constant $NS-X500                    =   40;
define inline-only constant $NS-NIS                     =   41;
define inline-only constant $NS-NISPLUS                 =   42;
define inline-only constant $NS-WRQ                     =   50;
define inline-only constant $RES-UNUSED-1               = #x00000001;
define inline-only constant $RES-FLUSH-CACHE            = #x00000002;
define inline-only constant $RES-SERVICE                = #x00000004;
define constant $SERVICE-TYPE-VALUE-IPXPORT = "IpxSocket";
define constant $SERVICE-TYPE-VALUE-SAPID = "SapId";
define constant $SERVICE-TYPE-VALUE-TCPPORT = "TcpPort";
define constant $SERVICE-TYPE-VALUE-UDPPORT = "UdpPort";
define constant $SERVICE-TYPE-VALUE-OBJECTID = "ObjectId";

define C-struct <SOCKET-ADDRESS>
  sealed inline-only slot lpSockaddr-value :: <LPSOCKADDR>;
  sealed inline-only slot iSockaddrLength-value :: <INT>;
  pack: 4;
  pointer-type-name: <LPSOCKET-ADDRESS>;
  c-name: "struct _SOCKET_ADDRESS";
end C-struct <SOCKET-ADDRESS>;
define inline constant <PSOCKET-ADDRESS> = <LPSOCKET-ADDRESS>;

define C-struct <CSADDR-INFO>
  sealed inline-only slot LocalAddr-value :: <SOCKET-ADDRESS>;
  sealed inline-only slot RemoteAddr-value :: <SOCKET-ADDRESS>;
  sealed inline-only slot iSocketType-value :: <INT>;
  sealed inline-only slot iProtocol-value :: <INT>;
  pack: 4;
  pointer-type-name: <LPCSADDR-INFO>;
  c-name: "struct _CSADDR_INFO";
end C-struct <CSADDR-INFO>;
define inline constant <PCSADDR-INFO> = <LPCSADDR-INFO>;

define C-struct <SOCKET-ADDRESS-LIST>
  sealed inline-only slot iAddressCount-value :: <INT>;
  sealed inline-only array slot Address-array :: <SOCKET-ADDRESS>,
	length: 1, address-getter: Address-value;
  pack: 4;
  pointer-type-name: <LPSOCKET-ADDRESS-LIST>;
  c-name: "struct _SOCKET_ADDRESS_LIST";
end C-struct <SOCKET-ADDRESS-LIST>;

define C-struct <AFPROTOCOLS>
  sealed inline-only slot iAddressFamily-value :: <INT>;
  sealed inline-only slot iProtocol-value :: <INT>;
  pack: 4;
  pointer-type-name: <LPAFPROTOCOLS>;
  c-name: "struct _AFPROTOCOLS";
end C-struct <AFPROTOCOLS>;
define inline constant <PAFPROTOCOLS> = <LPAFPROTOCOLS>;
// enum WSAECOMPARATOR:
define inline-only constant $COMP-EQUAL = 0;
define inline-only constant $COMP-NOTLESS = 0 + 1;


define C-struct <WSAVERSION>
  sealed inline-only slot dwVersion-value :: <DWORD>;
  sealed inline-only slot ecHow-value    :: <C-int>;
  pack: 4;
  pointer-type-name: <LPWSAVERSION>;
  c-name: "struct _WSAVersion";
end C-struct <WSAVERSION>;
define inline constant <PWSAVERSION> = <LPWSAVERSION>;

define C-struct <WSAQUERYSETA>
  sealed inline-only slot dwSize-value   :: <DWORD>;
  sealed inline-only slot lpszServiceInstanceName-value :: <LPSTR>;
  sealed inline-only slot lpServiceClassId-value :: <LPGUID>;
  sealed inline-only slot lpVersion-value :: <LPWSAVERSION>;
  sealed inline-only slot lpszComment-value :: <LPSTR>;
  sealed inline-only slot dwNameSpace-value :: <DWORD>;
  sealed inline-only slot lpNSProviderId-value :: <LPGUID>;
  sealed inline-only slot lpszContext-value :: <LPSTR>;
  sealed inline-only slot dwNumberOfProtocols-value :: <DWORD>;
  sealed inline-only slot lpafpProtocols-value :: <LPAFPROTOCOLS>;
  sealed inline-only slot lpszQueryString-value :: <LPSTR>;
  sealed inline-only slot dwNumberOfCsAddrs-value :: <DWORD>;
  sealed inline-only slot lpcsaBuffer-value :: <LPCSADDR-INFO>;
  sealed inline-only slot dwOutputFlags-value :: <DWORD>;
  sealed inline-only slot lpBlob-value   :: <LPBLOB>;
  pack: 4;
  pointer-type-name: <LPWSAQUERYSETA>;
  c-name: "struct _WSAQuerySetA";
end C-struct <WSAQUERYSETA>;
define inline constant <PWSAQUERYSETA> = <LPWSAQUERYSETA>;

define C-struct <WSAQUERYSETW>
  sealed inline-only slot dwSize-value   :: <DWORD>;
  sealed inline-only slot lpszServiceInstanceName-value :: <LPWSTR>;
  sealed inline-only slot lpServiceClassId-value :: <LPGUID>;
  sealed inline-only slot lpVersion-value :: <LPWSAVERSION>;
  sealed inline-only slot lpszComment-value :: <LPWSTR>;
  sealed inline-only slot dwNameSpace-value :: <DWORD>;
  sealed inline-only slot lpNSProviderId-value :: <LPGUID>;
  sealed inline-only slot lpszContext-value :: <LPWSTR>;
  sealed inline-only slot dwNumberOfProtocols-value :: <DWORD>;
  sealed inline-only slot lpafpProtocols-value :: <LPAFPROTOCOLS>;
  sealed inline-only slot lpszQueryString-value :: <LPWSTR>;
  sealed inline-only slot dwNumberOfCsAddrs-value :: <DWORD>;
  sealed inline-only slot lpcsaBuffer-value :: <LPCSADDR-INFO>;
  sealed inline-only slot dwOutputFlags-value :: <DWORD>;
  sealed inline-only slot lpBlob-value   :: <LPBLOB>;
  pack: 4;
  pointer-type-name: <LPWSAQUERYSETW>;
  c-name: "struct _WSAQuerySetW";
end C-struct <WSAQUERYSETW>;
define inline constant <PWSAQUERYSETW> = <LPWSAQUERYSETW>;
define inline constant <WSAQUERYSET> = <WSAQUERYSETA>;
define inline constant <PWSAQUERYSET> = <PWSAQUERYSETA>;
define inline constant <LPWSAQUERYSET> = <LPWSAQUERYSETA>;
define inline-only constant $LUP-DEEP                   = #x0001;
define inline-only constant $LUP-CONTAINERS             = #x0002;
define inline-only constant $LUP-NOCONTAINERS           = #x0004;
define inline-only constant $LUP-NEAREST                = #x0008;
define inline-only constant $LUP-RETURN-NAME            = #x0010;
define inline-only constant $LUP-RETURN-TYPE            = #x0020;
define inline-only constant $LUP-RETURN-VERSION         = #x0040;
define inline-only constant $LUP-RETURN-COMMENT         = #x0080;
define inline-only constant $LUP-RETURN-ADDR            = #x0100;
define inline-only constant $LUP-RETURN-BLOB            = #x0200;
define inline-only constant $LUP-RETURN-ALIASES         = #x0400;
define inline-only constant $LUP-RETURN-QUERY-STRING    = #x0800;
define inline-only constant $LUP-RETURN-ALL             = #x0FF0;
define inline-only constant $LUP-RES-SERVICE            = #x8000;
define inline-only constant $LUP-FLUSHCACHE             = #x1000;
define inline-only constant $LUP-FLUSHPREVIOUS          = #x2000;
define inline-only constant $RESULT-IS-ALIAS            = #x0001;
// enum WSAESETSERVICEOP:
define inline-only constant $RNRSERVICE-REGISTER = 0;
define inline-only constant $RNRSERVICE-DEREGISTER = 0 + 1;
define inline-only constant $RNRSERVICE-DELETE = $RNRSERVICE-DEREGISTER + 1;


define C-struct <WSANSCLASSINFOA>
  sealed inline-only slot lpszName-value :: <LPSTR>;
  sealed inline-only slot dwNameSpace-value :: <DWORD>;
  sealed inline-only slot dwValueType-value :: <DWORD>;
  sealed inline-only slot dwValueSize-value :: <DWORD>;
  sealed inline-only slot lpValue-value  :: <LPVOID>;
  pack: 4;
  pointer-type-name: <LPWSANSCLASSINFOA>;
  c-name: "struct _WSANSClassInfoA";
end C-struct <WSANSCLASSINFOA>;
define inline constant <PWSANSCLASSINFOA> = <LPWSANSCLASSINFOA>;

define C-struct <WSANSCLASSINFOW>
  sealed inline-only slot lpszName-value :: <LPWSTR>;
  sealed inline-only slot dwNameSpace-value :: <DWORD>;
  sealed inline-only slot dwValueType-value :: <DWORD>;
  sealed inline-only slot dwValueSize-value :: <DWORD>;
  sealed inline-only slot lpValue-value  :: <LPVOID>;
  pack: 4;
  pointer-type-name: <LPWSANSCLASSINFOW>;
  c-name: "struct _WSANSClassInfoW";
end C-struct <WSANSCLASSINFOW>;
define inline constant <PWSANSCLASSINFOW> = <LPWSANSCLASSINFOW>;
define inline constant <WSANSCLASSINFO> = <WSANSCLASSINFOA>;
define inline constant <PWSANSCLASSINFO> = <PWSANSCLASSINFOA>;
define inline constant <LPWSANSCLASSINFO> = <LPWSANSCLASSINFOA>;

define C-struct <WSASERVICECLASSINFOA>
  sealed inline-only slot lpServiceClassId-value :: <LPGUID>;
  sealed inline-only slot lpszServiceClassName-value :: <LPSTR>;
  sealed inline-only slot dwCount-value  :: <DWORD>;
  sealed inline-only slot lpClassInfos-value :: <LPWSANSCLASSINFOA>;
  pack: 4;
  pointer-type-name: <LPWSASERVICECLASSINFOA>;
  c-name: "struct _WSAServiceClassInfoA";
end C-struct <WSASERVICECLASSINFOA>;
define inline constant <PWSASERVICECLASSINFOA> = <LPWSASERVICECLASSINFOA>;

define C-struct <WSASERVICECLASSINFOW>
  sealed inline-only slot lpServiceClassId-value :: <LPGUID>;
  sealed inline-only slot lpszServiceClassName-value :: <LPWSTR>;
  sealed inline-only slot dwCount-value  :: <DWORD>;
  sealed inline-only slot lpClassInfos-value :: <LPWSANSCLASSINFOW>;
  pack: 4;
  pointer-type-name: <LPWSASERVICECLASSINFOW>;
  c-name: "struct _WSAServiceClassInfoW";
end C-struct <WSASERVICECLASSINFOW>;
define inline constant <PWSASERVICECLASSINFOW> = <LPWSASERVICECLASSINFOW>;
define inline constant <WSASERVICECLASSINFO> = <WSASERVICECLASSINFOA>;
define inline constant <PWSASERVICECLASSINFO> = <PWSASERVICECLASSINFOA>;
define inline constant <LPWSASERVICECLASSINFO> = <LPWSASERVICECLASSINFOA>;

define C-struct <WSANAMESPACE-INFOA>
  sealed inline-only slot NSProviderId-value :: <GUID>;
  sealed inline-only slot dwNameSpace-value :: <DWORD>;
  sealed inline-only slot fActive-value  :: <BOOL>;
  sealed inline-only slot dwVersion-value :: <DWORD>;
  sealed inline-only slot lpszIdentifier-value :: <LPSTR>;
  pack: 4;
  pointer-type-name: <LPWSANAMESPACE-INFOA>;
  c-name: "struct _WSANAMESPACE_INFOA";
end C-struct <WSANAMESPACE-INFOA>;
define inline constant <PWSANAMESPACE-INFOA> = <LPWSANAMESPACE-INFOA>;

define C-struct <WSANAMESPACE-INFOW>
  sealed inline-only slot NSProviderId-value :: <GUID>;
  sealed inline-only slot dwNameSpace-value :: <DWORD>;
  sealed inline-only slot fActive-value  :: <BOOL>;
  sealed inline-only slot dwVersion-value :: <DWORD>;
  sealed inline-only slot lpszIdentifier-value :: <LPWSTR>;
  pack: 4;
  pointer-type-name: <LPWSANAMESPACE-INFOW>;
  c-name: "struct _WSANAMESPACE_INFOW";
end C-struct <WSANAMESPACE-INFOW>;
define inline constant <PWSANAMESPACE-INFOW> = <LPWSANAMESPACE-INFOW>;
define inline constant <WSANAMESPACE-INFO> = <WSANAMESPACE-INFOA>;
define inline constant <PWSANAMESPACE-INFO> = <PWSANAMESPACE-INFOA>;
define inline constant <LPWSANAMESPACE-INFO> = <LPWSANAMESPACE-INFOA>;

define inline-only C-function accept
  parameter s          :: <C-SOCKET>;
  parameter addr       :: <LPSOCKADDR>;
  parameter addrlen    :: <C-int*>;
  result value :: <C-SOCKET>;
  c-name: "accept", c-modifiers: "__stdcall";
end;

define inline-only C-function bind
  parameter s          :: <C-SOCKET>;
  parameter name       ::  /* const */ <LPSOCKADDR>;
  parameter namelen    :: <C-int>;
  result value :: <C-int>;
  c-name: "bind", c-modifiers: "__stdcall";
end;

define inline-only C-function closesocket
  parameter s          :: <C-SOCKET>;
  result value :: <C-int>;
  c-name: "closesocket", c-modifiers: "__stdcall";
end;

define inline-only C-function connect
  parameter s          :: <C-SOCKET>;
  parameter name       ::  /* const */ <LPSOCKADDR>;
  parameter namelen    :: <C-int>;
  result value :: <C-int>;
  c-name: "connect", c-modifiers: "__stdcall";
end;

define inline-only C-function ioctlsocket
  parameter s          :: <C-SOCKET>;
  parameter cmd        :: <C-both-long>;
  parameter argp       :: <C-both-unsigned-long*>;
  result value :: <C-int>;
  c-name: "ioctlsocket", c-modifiers: "__stdcall";
end;

define inline-only C-function getpeername
  parameter s          :: <C-SOCKET>;
  parameter name       :: <LPSOCKADDR>;
  parameter namelen    :: <C-int*>;
  result value :: <C-int>;
  c-name: "getpeername", c-modifiers: "__stdcall";
end;

define inline-only C-function getsockname
  parameter s          :: <C-SOCKET>;
  parameter name       :: <LPSOCKADDR>;
  parameter namelen    :: <C-int*>;
  result value :: <C-int>;
  c-name: "getsockname", c-modifiers: "__stdcall";
end;

define inline-only C-function getsockopt
  parameter s          :: <C-SOCKET>;
  parameter level      :: <C-int>;
  parameter optname    :: <C-int>;
  parameter optval     :: <C-char*>;
  parameter optlen     :: <C-int*>;
  result value :: <C-int>;
  c-name: "getsockopt", c-modifiers: "__stdcall";
end;

define inline-only C-function htonl
  parameter hostlong   :: <C-raw-unsigned-long>;
  result value :: <C-raw-unsigned-long>;
  c-name: "htonl", c-modifiers: "__stdcall";
end;

define inline-only C-function htons
  parameter hostshort  :: <u-short>;
  result value :: <u-short>;
  c-name: "htons", c-modifiers: "__stdcall";
end;

define inline-only C-function inet-addr
  parameter cp         ::  /* const */ <C-char*>;
  result value :: <C-raw-unsigned-long>;
  c-name: "inet_addr", c-modifiers: "__stdcall";
end;

define inline-only C-function inet-ntoa
  parameter in         :: <in-addr>;
  result value :: <C-char*>;
  c-name: "inet_ntoa", c-modifiers: "__stdcall";
end;

define inline-only C-function listen
  parameter s          :: <C-SOCKET>;
  parameter backlog    :: <C-int>;
  result value :: <C-int>;
  c-name: "listen", c-modifiers: "__stdcall";
end;

define inline-only C-function ntohl
  parameter netlong    :: <C-raw-unsigned-long>;
  result value :: <C-raw-unsigned-long>;
  c-name: "ntohl", c-modifiers: "__stdcall";
end;

define inline-only C-function ntohs
  parameter netshort   :: <u-short>;
  result value :: <u-short>;
  c-name: "ntohs", c-modifiers: "__stdcall";
end;

define inline-only C-function recv
  parameter s          :: <C-SOCKET>;
  parameter buf        :: <C-char*>;
  parameter len        :: <C-int>;
  parameter flags      :: <C-int>;
  result value :: <C-int>;
  c-name: "recv", c-modifiers: "__stdcall";
end;

define inline-only C-function recvfrom
  parameter s          :: <C-SOCKET>;
  parameter buf        :: <C-char*>;
  parameter len        :: <C-int>;
  parameter flags      :: <C-int>;
  parameter from       :: <LPSOCKADDR>;
  parameter fromlen    :: <C-int*>;
  result value :: <C-int>;
  c-name: "recvfrom", c-modifiers: "__stdcall";
end;

define inline-only C-function winsock-select
  parameter nfds       :: <C-int>;
  parameter readfds    :: <LPfd-set>;
  parameter writefds   :: <LPfd-set>;
  parameter exceptfds  :: <LPfd-set>;
  parameter timeout    ::  /* const */ <LPTIMEVAL>;
  result value :: <C-int>;
  c-name: "select", c-modifiers: "__stdcall";
end;

define inline-only C-function send
  parameter s          :: <C-SOCKET>;
  parameter buf        ::  /* const */ <C-char*>;
  parameter len        :: <C-int>;
  parameter flags      :: <C-int>;
  result value :: <C-int>;
  c-name: "send", c-modifiers: "__stdcall";
end;

define inline-only C-function sendto
  parameter s          :: <C-SOCKET>;
  parameter buf        ::  /* const */ <C-char*>;
  parameter len        :: <C-int>;
  parameter flags      :: <C-int>;
  parameter to         ::  /* const */ <LPSOCKADDR>;
  parameter tolen      :: <C-int>;
  result value :: <C-int>;
  c-name: "sendto", c-modifiers: "__stdcall";
end;

define inline-only C-function setsockopt
  parameter s          :: <C-SOCKET>;
  parameter level      :: <C-int>;
  parameter optname    :: <C-int>;
  parameter optval     ::  /* const */ <C-char*>;
  parameter optlen     :: <C-int>;
  result value :: <C-int>;
  c-name: "setsockopt", c-modifiers: "__stdcall";
end;

define inline-only C-function shutdown
  parameter s          :: <C-SOCKET>;
  parameter how        :: <C-int>;
  result value :: <C-int>;
  c-name: "shutdown", c-modifiers: "__stdcall";
end;

define inline-only C-function socket
  parameter af         :: <C-int>;
  parameter type       :: <C-int>;
  parameter protocol   :: <C-int>;
  result value :: <C-SOCKET>;
  c-name: "socket", c-modifiers: "__stdcall";
end;

define inline-only C-function gethostbyaddr
  parameter addr       ::  /* const */ <C-char*>;
  parameter len        :: <C-int>;
  parameter type       :: <C-int>;
  result value :: <LPHOSTENT>;
  c-name: "gethostbyaddr", c-modifiers: "__stdcall";
end;

define inline-only C-function gethostbyname
  parameter name       ::  /* const */ <C-char*>;
  result value :: <LPHOSTENT>;
  c-name: "gethostbyname", c-modifiers: "__stdcall";
end;

define inline-only C-function gethostname
  parameter name       :: <C-char*>;
  parameter namelen    :: <C-int>;
  result value :: <C-int>;
  c-name: "gethostname", c-modifiers: "__stdcall";
end;

define inline-only C-function getservbyport
  parameter port       :: <C-int>;
  parameter proto      ::  /* const */ <C-char*>;
  result value :: <LPSERVENT>;
  c-name: "getservbyport", c-modifiers: "__stdcall";
end;

define inline-only C-function getservbyname
  parameter name       ::  /* const */ <C-char*>;
  parameter proto      ::  /* const */ <C-char*>;
  result value :: <LPSERVENT>;
  c-name: "getservbyname", c-modifiers: "__stdcall";
end;

define inline-only C-function getprotobynumber
  parameter number     :: <C-int>;
  result value :: <LPPROTOENT>;
  c-name: "getprotobynumber", c-modifiers: "__stdcall";
end;

define inline-only C-function getprotobyname
  parameter name       ::  /* const */ <C-char*>;
  result value :: <LPPROTOENT>;
  c-name: "getprotobyname", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAStartup
  parameter wVersionRequested :: <WORD>;
  parameter lpWSAData  :: <LPWSADATA>;
  result value :: <C-int>;
  c-name: "WSAStartup", c-modifiers: "__stdcall";
end;

define inline-only C-function WSACleanup
  result value :: <C-int>;
  c-name: "WSACleanup", c-modifiers: "__stdcall";
end;

define inline-only C-function WSASetLastError
  parameter iError     :: <C-int>;
  c-name: "WSASetLastError", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAGetLastError
  result value :: <C-int>;
  c-name: "WSAGetLastError", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncGetServByName
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter name       ::  /* const */ <C-char*>;
  parameter proto      ::  /* const */ <C-char*>;
  parameter buf        :: <C-char*>;
  parameter buflen     :: <C-int>;
  result value :: <HANDLE>;
  c-name: "WSAAsyncGetServByName", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncGetServByPort
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter port       :: <C-int>;
  parameter proto      ::  /* const */ <C-char*>;
  parameter buf        :: <C-char*>;
  parameter buflen     :: <C-int>;
  result value :: <HANDLE>;
  c-name: "WSAAsyncGetServByPort", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncGetProtoByName
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter name       ::  /* const */ <C-char*>;
  parameter buf        :: <C-char*>;
  parameter buflen     :: <C-int>;
  result value :: <HANDLE>;
  c-name: "WSAAsyncGetProtoByName", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncGetProtoByNumber
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter number     :: <C-int>;
  parameter buf        :: <C-char*>;
  parameter buflen     :: <C-int>;
  result value :: <HANDLE>;
  c-name: "WSAAsyncGetProtoByNumber", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncGetHostByName
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter name       ::  /* const */ <C-char*>;
  parameter buf        :: <C-char*>;
  parameter buflen     :: <C-int>;
  result value :: <HANDLE>;
  c-name: "WSAAsyncGetHostByName", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncGetHostByAddr
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter addr       ::  /* const */ <C-char*>;
  parameter len        :: <C-int>;
  parameter type       :: <C-int>;
  parameter buf        :: <C-char*>;
  parameter buflen     :: <C-int>;
  result value :: <HANDLE>;
  c-name: "WSAAsyncGetHostByAddr", c-modifiers: "__stdcall";
end;

define inline-only C-function WSACancelAsyncRequest
  parameter hAsyncTaskHandle :: <HANDLE>;
  result value :: <C-int>;
  c-name: "WSACancelAsyncRequest", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAsyncSelect
  parameter s          :: <C-SOCKET>;
  parameter hWnd       :: <HWND>;
  parameter wMsg       :: <u-int>;
  parameter lEvent     :: <C-both-long>;
  result value :: <C-int>;
  c-name: "WSAAsyncSelect", c-modifiers: "__stdcall";
end;
define constant <LPCONDITIONPROC> = <C-function-pointer>;
define constant <LPWSAOVERLAPPED-COMPLETION-ROUTINE> = <C-function-pointer>;

define inline-only C-function WSAAccept
  parameter s          :: <C-SOCKET>;
  parameter addr       :: <LPSOCKADDR>;
  output parameter addrlen :: <LPint>;
  parameter lpfnCondition :: <LPCONDITIONPROC>;
  parameter dwCallbackData :: <DWORD>;
  result value :: <C-SOCKET>;
  c-name: "WSAAccept", c-modifiers: "__stdcall";
end;

define inline-only C-function WSACloseEvent
  parameter hEvent     :: <WSAEVENT>;
  result value :: <BOOL>;
  c-name: "WSACloseEvent", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAConnect
  parameter s          :: <C-SOCKET>;
  parameter name       ::  /* const */ <LPSOCKADDR>;
  parameter namelen    :: <C-int>;
  parameter lpCallerData :: <LPWSABUF>;
  parameter lpCalleeData :: <LPWSABUF>;
  parameter lpSQOS     :: <LPQOS>;
  parameter lpGQOS     :: <LPQOS>;
  result value :: <C-int>;
  c-name: "WSAConnect", c-modifiers: "__stdcall";
end;

define inline-only C-function WSACreateEvent
  result value :: <WSAEVENT>;
  c-name: "WSACreateEvent", c-modifiers: "__stdcall";
end;

define inline-only C-function WSADuplicateSocket
  parameter s          :: <C-SOCKET>;
  parameter dwProcessId :: <DWORD>;
  parameter lpProtocolInfo :: <LPWSAPROTOCOL-INFOA>;
  result value :: <C-int>;
  c-name: "WSADuplicateSocketA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAEnumNetworkEvents
  parameter s          :: <C-SOCKET>;
  parameter hEventObject :: <WSAEVENT>;
  parameter lpNetworkEvents :: <LPWSANETWORKEVENTS>;
  result value :: <C-int>;
  c-name: "WSAEnumNetworkEvents", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAEnumProtocols
  output parameter lpiProtocols :: <LPint>;
  parameter lpProtocolBuffer :: <LPWSAPROTOCOL-INFOA>;
  parameter lpdwBufferLength :: <LPDWORD>;
  result value :: <C-int>;
  c-name: "WSAEnumProtocolsA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAEventSelect
  parameter s          :: <C-SOCKET>;
  parameter hEventObject :: <WSAEVENT>;
  parameter lNetworkEvents :: <C-both-long>;
  result value :: <C-int>;
  c-name: "WSAEventSelect", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAGetOverlappedResult
  parameter s          :: <C-SOCKET>;
  parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  output parameter lpcbTransfer :: <LPDWORD>;
  parameter fWait      :: <BOOL>;
  output parameter lpdwFlags :: <LPDWORD>;
  result value :: <BOOL>;
  c-name: "WSAGetOverlappedResult", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAGetQOSByName
  parameter s          :: <C-SOCKET>;
  parameter lpQOSName  :: <LPWSABUF>;
  parameter lpQOS      :: <LPQOS>;
  result value :: <BOOL>;
  c-name: "WSAGetQOSByName", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAHtonl
  parameter s          :: <C-SOCKET>;
  parameter hostlong   :: <C-raw-unsigned-long>;
  parameter lpnetlong  :: <C-both-unsigned-long*>;
  result value :: <C-int>;
  c-name: "WSAHtonl", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAHtons
  parameter s          :: <C-SOCKET>;
  parameter hostshort  :: <u-short>;
  parameter lpnetshort :: <C-unsigned-short*>;
  result value :: <C-int>;
  c-name: "WSAHtons", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAIoctl
  parameter s          :: <C-SOCKET>;
  parameter dwIoControlCode :: <DWORD>;
  parameter lpvInBuffer :: <LPVOID>;
  parameter cbInBuffer :: <DWORD>;
  parameter lpvOutBuffer :: <LPVOID>;
  parameter cbOutBuffer :: <DWORD>;
  output parameter lpcbBytesReturned :: <LPDWORD>;
  parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  parameter lpCompletionRoutine :: <LPWSAOVERLAPPED-COMPLETION-ROUTINE>;
  result value :: <C-int>;
  c-name: "WSAIoctl", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAJoinLeaf
  parameter s          :: <C-SOCKET>;
  parameter name       ::  /* const */ <LPSOCKADDR>;
  parameter namelen    :: <C-int>;
  parameter lpCallerData :: <LPWSABUF>;
  parameter lpCalleeData :: <LPWSABUF>;
  parameter lpSQOS     :: <LPQOS>;
  parameter lpGQOS     :: <LPQOS>;
  parameter dwFlags    :: <DWORD>;
  result value :: <C-SOCKET>;
  c-name: "WSAJoinLeaf", c-modifiers: "__stdcall";
end;

define inline-only C-function WSANtohl
  parameter s          :: <C-SOCKET>;
  parameter netlong    :: <C-raw-unsigned-long>;
  parameter lphostlong :: <C-both-unsigned-long*>;
  result value :: <C-int>;
  c-name: "WSANtohl", c-modifiers: "__stdcall";
end;

define inline-only C-function WSANtohs
  parameter s          :: <C-SOCKET>;
  parameter netshort   :: <u-short>;
  parameter lphostshort :: <C-unsigned-short*>;
  result value :: <C-int>;
  c-name: "WSANtohs", c-modifiers: "__stdcall";
end;

define inline-only C-function WSARecv
  parameter s          :: <C-SOCKET>;
  parameter lpBuffers  :: <LPWSABUF>;
  parameter dwBufferCount :: <DWORD>;
  output parameter lpNumberOfBytesRecvd :: <LPDWORD>;
  parameter lpFlags    :: <LPDWORD>;
  parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  parameter lpCompletionRoutine :: <LPWSAOVERLAPPED-COMPLETION-ROUTINE>;
  result value :: <C-int>;
  c-name: "WSARecv", c-modifiers: "__stdcall";
end;

define inline-only C-function WSARecvDisconnect
  parameter s          :: <C-SOCKET>;
  parameter lpInboundDisconnectData :: <LPWSABUF>;
  result value :: <C-int>;
  c-name: "WSARecvDisconnect", c-modifiers: "__stdcall";
end;

define inline-only C-function WSARecvFrom
  parameter s          :: <C-SOCKET>;
  parameter lpBuffers  :: <LPWSABUF>;
  parameter dwBufferCount :: <DWORD>;
  output parameter lpNumberOfBytesRecvd :: <LPDWORD>;
  parameter lpFlags    :: <LPDWORD>;
  parameter lpFrom     :: <LPSOCKADDR>;
  output parameter lpFromlen :: <LPint>;
  parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  parameter lpCompletionRoutine :: <LPWSAOVERLAPPED-COMPLETION-ROUTINE>;
  result value :: <C-int>;
  c-name: "WSARecvFrom", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAResetEvent
  parameter hEvent     :: <WSAEVENT>;
  result value :: <BOOL>;
  c-name: "WSAResetEvent", c-modifiers: "__stdcall";
end;

define inline-only C-function WSASend
  parameter s          :: <C-SOCKET>;
  parameter lpBuffers  :: <LPWSABUF>;
  parameter dwBufferCount :: <DWORD>;
  output parameter lpNumberOfBytesSent :: <LPDWORD>;
  parameter dwFlags    :: <DWORD>;
  parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  parameter lpCompletionRoutine :: <LPWSAOVERLAPPED-COMPLETION-ROUTINE>;
  result value :: <C-int>;
  c-name: "WSASend", c-modifiers: "__stdcall";
end;

define inline-only C-function WSASendDisconnect
  parameter s          :: <C-SOCKET>;
  parameter lpOutboundDisconnectData :: <LPWSABUF>;
  result value :: <C-int>;
  c-name: "WSASendDisconnect", c-modifiers: "__stdcall";
end;

define inline-only C-function WSASendTo
  parameter s          :: <C-SOCKET>;
  parameter lpBuffers  :: <LPWSABUF>;
  parameter dwBufferCount :: <DWORD>;
  output parameter lpNumberOfBytesSent :: <LPDWORD>;
  parameter dwFlags    :: <DWORD>;
  parameter lpTo       ::  /* const */ <LPSOCKADDR>;
  parameter iTolen     :: <C-int>;
  parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  parameter lpCompletionRoutine :: <LPWSAOVERLAPPED-COMPLETION-ROUTINE>;
  result value :: <C-int>;
  c-name: "WSASendTo", c-modifiers: "__stdcall";
end;

define inline-only C-function WSASetEvent
  parameter hEvent     :: <WSAEVENT>;
  result value :: <BOOL>;
  c-name: "WSASetEvent", c-modifiers: "__stdcall";
end;

define inline-only C-function WSASocket
  parameter af         :: <C-int>;
  parameter type       :: <C-int>;
  parameter protocol   :: <C-int>;
  parameter lpProtocolInfo :: <LPWSAPROTOCOL-INFOA>;
  parameter g          :: <GROUP>;
  parameter dwFlags    :: <DWORD>;
  result value :: <C-SOCKET>;
  c-name: "WSASocketA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAWaitForMultipleEvents
  parameter cEvents    :: <DWORD>;
  parameter lphEvents  ::  /* const */ <LPWSAEVENT>;
  parameter fWaitAll   :: <BOOL>;
  parameter dwTimeout  :: <DWORD>;
  parameter fAlertable :: <BOOL>;
  result value :: <DWORD>;
  c-name: "WSAWaitForMultipleEvents", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAAddressToString
  input parameter lpsaAddress :: <LPSOCKADDR>;
  input parameter dwAddressLength :: <DWORD>;
  input parameter lpProtocolInfo :: <LPWSAPROTOCOL-INFOA>;
  input output parameter lpszAddressString :: <LPSTR>;
  input output parameter lpdwAddressStringLength :: <LPDWORD>;
  result value :: <INT>;
  c-name: "WSAAddressToStringA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAStringToAddress
  input parameter AddressString :: <LPSTR>;
  input parameter AddressFamily :: <INT>;
  input parameter lpProtocolInfo :: <LPWSAPROTOCOL-INFOA>;
  input output parameter lpAddress :: <LPSOCKADDR>;
  input output parameter lpAddressLength :: <LPINT>;
  result value :: <INT>;
  c-name: "WSAStringToAddressA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSALookupServiceBegin
  input parameter lpqsRestrictions :: <LPWSAQUERYSETA>;
  input parameter dwControlFlags :: <DWORD>;
  output parameter lphLookup :: <LPHANDLE>;
  result value :: <INT>;
  c-name: "WSALookupServiceBeginA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSALookupServiceNext
  input parameter hLookup :: <HANDLE>;
  input parameter dwControlFlags :: <DWORD>;
  input output parameter lpdwBufferLength :: <LPDWORD>;
  output parameter lpqsResults :: <LPWSAQUERYSETA>;
  result value :: <INT>;
  c-name: "WSALookupServiceNextA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSALookupServiceEnd
  input parameter hLookup :: <HANDLE>;
  result value :: <INT>;
  c-name: "WSALookupServiceEnd", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAInstallServiceClass
  input parameter lpServiceClassInfo :: <LPWSASERVICECLASSINFOA>;
  result value :: <INT>;
  c-name: "WSAInstallServiceClassA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSARemoveServiceClass
  input parameter lpServiceClassId :: <LPGUID>;
  result value :: <INT>;
  c-name: "WSARemoveServiceClass", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAGetServiceClassInfo
  input parameter lpProviderId :: <LPGUID>;
  input parameter lpServiceClassId :: <LPGUID>;
  input output parameter lpdwBufSize :: <LPDWORD>;
  output parameter lpServiceClassInfo :: <LPWSASERVICECLASSINFOA>;
  result value :: <INT>;
  c-name: "WSAGetServiceClassInfoA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAEnumNameSpaceProviders
  input output parameter lpdwBufferLength :: <LPDWORD>;
  input parameter lpnspBuffer :: <LPWSANAMESPACE-INFOA>;
  result value :: <INT>;
  c-name: "WSAEnumNameSpaceProvidersA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAGetServiceClassNameByClassId
  input parameter lpServiceClassId :: <LPGUID>;
  output parameter lpszServiceClassName :: <LPSTR>;
  input output parameter lpdwBufferLength :: <LPDWORD>;
  result value :: <INT>;
  c-name: "WSAGetServiceClassNameByClassIdA"
	, c-modifiers: "__stdcall";
end;

define inline-only C-function WSASetService
  input parameter lpqsRegInfo :: <LPWSAQUERYSETA>;
  input parameter essoperation :: <C-int>;
  input parameter dwControlFlags :: <DWORD>;
  result value :: <INT>;
  c-name: "WSASetServiceA", c-modifiers: "__stdcall";
end;

define inline-only C-function WSAProviderConfigChange
  input output parameter lpNotificationHandle :: <LPHANDLE>;
  input parameter lpOverlapped :: <LPWSAOVERLAPPED>;
  input parameter lpCompletionRoutine :: <LPWSAOVERLAPPED-COMPLETION-ROUTINE>;
  result value :: <INT>;
  c-name: "WSAProviderConfigChange", c-modifiers: "__stdcall";
end;

define inline-only function WSAMAKEASYNCREPLY (buflen,error);
  MAKELONG(buflen,error)
end;

define inline-only function WSAMAKESELECTREPLY (event,error);
  MAKELONG(event,error)
end;

define inline-only function WSAGETASYNCBUFLEN (lParam);
  LOWORD(lParam)
end;

define inline-only function WSAGETASYNCERROR (lParam);
  HIWORD(lParam)
end;

define inline-only function WSAGETSELECTEVENT (lParam);
  LOWORD(lParam)
end;

define inline-only function WSAGETSELECTERROR (lParam);
  HIWORD(lParam)
end;

define sealed domain make (singleton(<LPfd-set>));
define sealed domain initialize (<LPfd-set>);
define inline-only constant $ADDR-ANY    = $INADDR-ANY;
define sealed domain make (singleton(<LPWSADATA>));
define sealed domain initialize (<LPWSADATA>);
define inline-only constant $AF-IPX      = $AF-NS;
define inline-only constant $AF-OSI      = $AF-ISO;
define inline-only constant $PF-UNSPEC   = $AF-UNSPEC;
define inline-only constant $PF-UNIX     = $AF-UNIX;
define inline-only constant $PF-INET     = $AF-INET;
define inline-only constant $PF-IMPLINK  = $AF-IMPLINK;
define inline-only constant $PF-PUP      = $AF-PUP;
define inline-only constant $PF-CHAOS    = $AF-CHAOS;
define inline-only constant $PF-NS       = $AF-NS;
define inline-only constant $PF-IPX      = $AF-IPX;
define inline-only constant $PF-ISO      = $AF-ISO;
define inline-only constant $PF-OSI      = $AF-OSI;
define inline-only constant $PF-ECMA     = $AF-ECMA;
define inline-only constant $PF-DATAKIT  = $AF-DATAKIT;
define inline-only constant $PF-CCITT    = $AF-CCITT;
define inline-only constant $PF-SNA      = $AF-SNA;
define inline-only constant $PF-DECnet   = $AF-DECnet;
define inline-only constant $PF-DLI      = $AF-DLI;
define inline-only constant $PF-LAT      = $AF-LAT;
define inline-only constant $PF-HYLINK   = $AF-HYLINK;
define inline-only constant $PF-APPLETALK = $AF-APPLETALK;
define inline-only constant $PF-VOICEVIEW = $AF-VOICEVIEW;
define inline-only constant $PF-FIREFOX  = $AF-FIREFOX;
define inline-only constant $PF-UNKNOWN1 = $AF-UNKNOWN1;
define inline-only constant $PF-BAN      = $AF-BAN;
define inline-only constant $PF-ATM      = $AF-ATM;
define inline-only constant $PF-INET6    = $AF-INET6;
define inline-only constant $PF-MAX      = $AF-MAX;
define inline-only constant $HOST-NOT-FOUND = $WSAHOST-NOT-FOUND;
define inline-only constant $TRY-AGAIN   = $WSATRY-AGAIN;
define inline-only constant $NO-RECOVERY = $WSANO-RECOVERY;
define inline-only constant $NO-DATA     = $WSANO-DATA;
define inline-only constant $WSANO-ADDRESS = $WSANO-DATA;
define inline-only constant $NO-ADDRESS  = $WSANO-ADDRESS;
define sealed domain make (singleton(<LPWSABUF>));
define sealed domain initialize (<LPWSABUF>);
define sealed domain make (singleton(<LPQOS>));
define sealed domain initialize (<LPQOS>);
define sealed domain make (singleton(<LPWSANETWORKEVENTS>));
define sealed domain initialize (<LPWSANETWORKEVENTS>);
define sealed domain make (singleton(<LPGUID>));
define sealed domain initialize (<LPGUID>);
define sealed domain make (singleton(<LPWSAPROTOCOLCHAIN>));
define sealed domain initialize (<LPWSAPROTOCOLCHAIN>);
define sealed domain make (singleton(<LPWSAPROTOCOL-INFOA>));
define sealed domain initialize (<LPWSAPROTOCOL-INFOA>);
define sealed domain make (singleton(<LPWSAPROTOCOL-INFOW>));
define sealed domain initialize (<LPWSAPROTOCOL-INFOW>);
define sealed domain make (singleton(<LPBLOB>));
define sealed domain initialize (<LPBLOB>);
define sealed domain make (singleton(<LPSOCKET-ADDRESS>));
define sealed domain initialize (<LPSOCKET-ADDRESS>);
define sealed domain make (singleton(<LPCSADDR-INFO>));
define sealed domain initialize (<LPCSADDR-INFO>);
define sealed domain make (singleton(<LPSOCKET-ADDRESS-LIST>));
define sealed domain initialize (<LPSOCKET-ADDRESS-LIST>);
define sealed domain make (singleton(<LPAFPROTOCOLS>));
define sealed domain initialize (<LPAFPROTOCOLS>);
define sealed domain make (singleton(<LPWSAVERSION>));
define sealed domain initialize (<LPWSAVERSION>);
define sealed domain make (singleton(<LPWSAQUERYSETA>));
define sealed domain initialize (<LPWSAQUERYSETA>);
define sealed domain make (singleton(<LPWSAQUERYSETW>));
define sealed domain initialize (<LPWSAQUERYSETW>);
define sealed domain make (singleton(<LPWSANSCLASSINFOA>));
define sealed domain initialize (<LPWSANSCLASSINFOA>);
define sealed domain make (singleton(<LPWSANSCLASSINFOW>));
define sealed domain initialize (<LPWSANSCLASSINFOW>);
define sealed domain make (singleton(<LPWSASERVICECLASSINFOA>));
define sealed domain initialize (<LPWSASERVICECLASSINFOA>);
define sealed domain make (singleton(<LPWSASERVICECLASSINFOW>));
define sealed domain initialize (<LPWSASERVICECLASSINFOW>);
define sealed domain make (singleton(<LPWSANAMESPACE-INFOA>));
define sealed domain initialize (<LPWSANAMESPACE-INFOA>);
define sealed domain make (singleton(<LPWSANAMESPACE-INFOW>));
define sealed domain initialize (<LPWSANAMESPACE-INFOW>);
