' ########################################################################################
' Microsoft Windows
' File: WinSock2.inc
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
'/* 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 Copyright (c) 1982-1986 Regents
' * of the University of California. All rights reserved. The
' * Berkeley Software License Agreement specifies the terms and
' * conditions for redistribution.
' */
#IF NOT %DEF(PBX_WinSock2_PBI)
#DEFINE PBX_WinSock2_PBI
%EQUATE `WINSOCK2_INC = 1
#IF NOT %DEF(%WINSOCK2API)
 %WINSOCK2API = 1
 %WINSOCKAPI = 1 ' Prevent inclusion of winsock.inc
'#ifndef _WINSOCK2API_
'#define _WINSOCK2API_
'#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
'/*
' * Ensure structures are packed consistently.
' * Not necessary for WIN32, it is already packed >=4 and there are
' * no structures in this header that have alignment requirement
' * higher than 4.
' * For WIN64 we do not have compatibility requirement because it is
' * not possible to mix 32/16 bit code with 64 bit code in the same
' * process.
' */
'#if !defined(WIN32) && !defined(_WIN64)
'#include <pshpack4.h>
'/* WIN32 can be defined between here and the required poppack
' so define this special macro to ensure poppack */
'#define _NEED_POPPACK
'#endif
'/*
' * Default: include function prototypes, don't include function typedefs.
' */
#IF NOT %DEF(%INCL_WINSOCK_API_PROTOTYPES)
%EQUATE `INCL_WINSOCK_API_PROTOTYPES = 1
#ENDIF
#IF NOT %DEF(%INCL_WINSOCK_API_TYPEDEFS)
%EQUATE `INCL_WINSOCK_API_TYPEDEFS = 0
#ENDIF
'/*
' * Pull in WINDOWS.H if necessary
' */
#IF NOT %DEF(%WINDOWS_INC)
 #INCLUDE ONCE "Core/Windows.inc"
#ENDIF
'/*
' * Define the current Winsock version. To build an earlier Winsock version
' * application redefine this value prior to including Winsock2.h.
' */
'#if !defined(MAKEWORD)
'#define MAKEWORD(low,high) \
' ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
'#endif
'#ifndef WINSOCK_VERSION
'#define WINSOCK_VERSION MAKEWORD(2,2)
'#endif
#IF NOT %DEF(%WINSOCK_VERSION)
%EQUATE `WINSOCK_VERSION = &H0202
#ENDIF
'/*
' * Basic system type definitions, taken from the BSD file sys/types.h.
' */
'typedef unsigned char u_char;
'typedef unsigned short u_short;
'typedef unsigned int u_int;
'typedef unsigned long u_long;
'typedef unsigned __int64 u_int64;
#INCLUDE ONCE "Legacy/System/ws2def.inc"
'/*
' * The new type to be used in all
' * instances which refer to sockets.
' */
'typedef UINT_PTR SOCKET;
'/*
' * Select uses arrays of SOCKETs. These macros manipulate such
' * arrays. FD_SETSIZE may be defined by the user before including
' * this file, but the default here should be >= 64.
' *
' * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
' * INCLUDED IN WINSOCK2.H EXACTLY AS SHOWN HERE.
' */
'#ifndef FD_SETSIZE
'#define FD_SETSIZE 64
'#endif /* FD_SETSIZE */
%EQUATE `FD_SETSIZE = 64
#IF %DEF(%USEPBDECL)
' // For compatibility with the PB declares
TYPE fd_set DWORD
 fd_count AS DWORD ' u_int // /* how many are SET? */
 fd_array(%FD_SETSIZE - 1) AS DWORD PTR ' SOCKET[FD_SETSIZE] // /* an array of SOCKETs */
END TYPE
#ELSE
' // Size = 260 bytes
TYPE fd_setstruc DWORD
 fd_count AS DWORD ' u_int // /* how many are SET? */
 fd_array(%FD_SETSIZE - 1) AS DWORD PTR ' SOCKET[FD_SETSIZE] // /* an array of SOCKETs */
END TYPE
MACRO FD_SET_STRUCT = fd_setstruc
#ENDIF
'extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAFDIsSet LIB "Ws2_32.dll" ALIAS "__WSAFDIsSet" ( BYVAL fd AS QUAD, ' SOCKET
 BYVAL fds AS fd_set PTR ) AS LONG
#ELSE
DECLARE FUNCTION WSAFDIsSet LIB "ws2_32.dll" ALIAS "__WSAFDIsSet" ( BYVAL s AS QUAD ' SOCKET , BYREF pfdset AS fd_setstruc ' fd_set FAR * ) AS LONG ' int
#ENDIF
'#define FD_CLR(fd, set) do { \
' u_int __i; \
' for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
' if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \
' while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
' ((fd_set FAR *)(set))->fd_array[__i] = \
' ((fd_set FAR *)(set))->fd_array[__i+1]; \
' } \
' ((fd_set FAR *)(set))->fd_count--; \
' break; \
' } \
' } \
'} while(0)
'#define FD_SET(fd, set) do { \
' u_int __i; \
' for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
' if (((fd_set FAR *)(set))->fd_array[__i] == (fd)) { \
' break; \
' } \
' } \
' if (__i == ((fd_set FAR *)(set))->fd_count) { \
' if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
' ((fd_set FAR *)(set))->fd_array[__i] = (fd); \
' ((fd_set FAR *)(set))->fd_count++; \
' } \
' } \
'} while(0)
'#define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)
'#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))
#IF %DEF(%USEPBDECL)
SUB FD_SET_sub (BYVAL fd AS DWORD, BYVAL fdset AS fd_set PTR)
 LOCAL i AS DWORD
 FOR i = 0 TO @fdset.fd_count - 1
 IF @fdset.fd_array(i) = fd THEN
 EXIT FOR
 END IF
 NEXT
 IF i = @fdset.fd_count THEN
 IF @fdset.fd_count < %FD_SETSIZE THEN
 @fdset.fd_array(i) = fd
 INCR @fdset.fd_count
 END IF
 END IF
END SUB
#ELSE
SUB FD_SET (BYVAL s AS DWORD, BYREF fds AS fd_setstruc)
 IF fds.fd_count < %FD_SETSIZE THEN
 fds.fd_array(fds.fd_count) = s
 INCR fds.fd_count
 END IF
END SUB
#ENDIF
#IF %DEF(%USEPBDECL)
SUB FD_ZERO (BYVAL fdset AS fd_set PTR)
 @fdset.fd_count = 0
END SUB
#ELSE
SUB FD_ZERO (BYREF fd AS fd_setstruc)
 fd.fd_count = 0
END SUB
#ENDIF
#IF %DEF(%USEPBDECL)
MACRO FD_ISSET = WSAFDIsSet
#ELSE
FUNCTION FD_ISSET (BYVAL fd AS DWORD, BYREF fds AS fd_setstruc) AS LONG
 FUNCTION = WSAFDIsSet(fd, fds)
END FUNCTION
#ENDIF
'/*
' * Structure used in select() call, taken from the BSD file sys/time.h.
' */
' // Size = 8 bytes
TYPE timeval DWORD
 tv_sec AS LONG ' long /* seconds */
 tv_usec AS LONG ' long /* and microseconds */
END TYPE
'/*
' * Operations on timevals.
' *
' * NB: timercmp does not work for >= or <=.
' */
'#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
'#define timercmp(tvp, uvp, cmp) \
' ((tvp)->tv_sec cmp (uvp)->tv_sec || \
' (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
'#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
#IF %DEF(%USEPBDECL)
MACRO timerisset(tvp)=(@tvp.tv_sec OR @tvp.tv_usec)
#ELSE
MACRO timerisset (tvp) = (tvp.tv_sec OR tvp.tv_usec)
#ENDIF
#IF %DEF(%USEPBDECL)
MACRO timerclear(tvp)
 @tvp.tv_usec = 0
 @tvp.tv_sec = 0
END MACRO
#ELSE
MACRO timerclear (tvp)
 tvp.tv_sec = 0
 tvp.tv_usec = 0
END MACRO
#ENDIF
%EQUATE `FIONREAD = &H4004667F ' _IOR('f', 127, u_long) /* get # bytes to read */
%EQUATE `FIONBIO = &H8004667E ' _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
%EQUATE `FIONSYNC = &H8004667D ' _IOW('f', 125, u_long) /* set/clear async i/o */
'/* Socket I/O Controls */
%EQUATE `SIOCSHIWAT = &H80047300 ' _IOW('s', 0, u_long) /* set high watermark */
%EQUATE `SIOCGHIWAT = &H80047301 ' _IOR('s', 1, u_long) /* get high watermark */
%EQUATE `SIOCSLOWAT = &H80047302 ' _IOW('s', 2, u_long) /* set low watermark */
%EQUATE `SIOCGLOWAT = &H80047303 ' _IOR('s', 3, u_long) /* get low watermark */
%EQUATE `SIOCATMARK = &H80047307 ' _IOR('s', 7, u_long) /* at oob mark? */
'/*
' * Structures returned by network data base library, taken from the
' * BSD file netdb.h. All addresses are supplied in host order, and
' * returned in network order (suitable for use in system calls).
' */
'struct hostent {
' char FAR * h_name; /* official name of host */
' char FAR * FAR * h_aliases; /* alias list */
' short h_addrtype; /* host address type */
' short h_length; /* length of address */
' char FAR * FAR * h_addr_list; /* list of addresses */
'#define h_addr h_addr_list[0] /* address, for backward compat */
'};
' // Size = 16 bytes
TYPE hostent DWORD FILL
 h_name AS ASCIIZ PTR ' char FAR * /* official name of host */
 h_aliases AS DWORD ' char FAR* FAR* /* alias list */
 h_addrtype AS INTEGER ' short /* host address type */
 h_length AS INTEGER ' short /* length of address */
 h_addr_list AS DWORD ' char FAR* FAR* /* list of addresses */
END TYPE
'/*
' * It is assumed here that a network number
' * fits in 32 bits.
' */
' // Size = 16 bytes
TYPE netent DWORD
 n_name AS ASCIIZ PTR ' char FAR * /* official name of net */
 n_aliases AS DWORD ' char FAR * FAR * /* alias list */
 n_addrtype AS INTEGER ' short /* net address type */
 n_net AS DWORD ' u_long /* network # */
END TYPE
' // Size = 16 bytes
TYPE servent DWORD
 s_name AS ASCIIZ PTR ' char FAR* /* official service name */
 s_aliases AS DWORD ' char FAR * FAR * /* alias list */
'#ifdef _WIN64
' char FAR * s_proto; /* protocol to use */
' short s_port; /* port # */
'#else
 s_port AS INTEGER ' short /* port # */
 s_proto AS ASCIIZ PTR ' char FAR * /* protocol to use */
'#endif
END TYPE
' // Size = 12 bytes
TYPE protoent DWORD
 p_name AS ASCIIZ PTR ' char FAR * /* official protocol name */
 p_aliases AS DWORD ' char FAR * FAR * /* alias list */
 p_proto AS INTEGER ' short /* protocol # */
END TYPE
'/*
' * Link numbers
' */
%EQUATE `IMPLINK_IP = 155
%EQUATE `IMPLINK_LOWEXPER = 156
%EQUATE `IMPLINK_HIGHEXPER = 158
#INCLUDE ONCE "Legacy/System/inaddr.inc"
%EQUATE `ADDR_ANY = &H00000000 ' %INADDR_ANY
%EQUATE `WSADESCRIPTION_LEN = 256
%EQUATE `WSASYS_STATUS_LEN = 128
' // Size = 400 bytes
TYPE WSADATA DWORD FILL
 wVersion AS WORD ' WORD
 wHighVersion AS WORD ' WORD
'#ifdef _WIN64
' unsigned short iMaxSockets;
' unsigned short iMaxUdpDg;
' char FAR * lpVendorInfo;
' char szDescription[WSADESCRIPTION_LEN+1];
' char szSystemStatus[WSASYS_STATUS_LEN+1];
'#else
 szDescription AS ASCIIZ * %WSADESCRIPTION_LEN + 1 ' char[WSADESCRIPTION_LEN+1]
 szSystemStatus AS ASCIIZ * %WSASYS_STATUS_LEN + 1 ' char[WSASYS_STATUS_LEN+1]
 iMaxSockets AS WORD ' unsigned short
 iMaxUdpDg AS WORD ' unsigned short
 lpVendorInfo AS ASCIIZ PTR ' char FAR *
'#endif
END TYPE
'/*
' * Definitions related to sockets: types, address families, options,
' * taken from the BSD file sys/socket.h.
' */
'/*
' * This is used instead of -1, since the
' * SOCKET type is unsigned.
' */
%EQUATE `INVALID_SOCKET = &HFFFFFFFF ' (SOCKET)(~0)
%EQUATE `SOCKET_ERROR = -1 ' (-1)
'/*
' * The following may be used in place of the address family, socket type, or
' * protocol in a call to WSASocket to indicate that the corresponding value
' * should be taken from the supplied WSAPROTOCOL_INFO structure instead of the
' * parameter itself.
' */
%EQUATE `FROM_PROTOCOL_INFO = -1
'/*
' * Types
' */
%EQUATE `SOCK_STREAM = 1 ' stream socket
%EQUATE `SOCK_DGRAM = 2 ' datagram socket
%EQUATE `SOCK_RAW = 3 ' raw-protocol interface
%EQUATE `SOCK_RDM = 4 ' reliably-delivered message
%EQUATE `SOCK_SEQPACKET = 5 ' sequenced packet stream
'/*
' * Option flags per-socket.
' */
%EQUATE `SO_DEBUG = &H0001 ' turn on debugging info recording
%EQUATE `SO_ACCEPTCONN = &H0002 ' socket has had listen()
%EQUATE `SO_REUSEADDR = &H0004 ' allow local address reuse
%EQUATE `SO_KEEPALIVE = &H0008 ' keep connections alive
%EQUATE `SO_DONTROUTE = &H0010 ' just use interface addresses
%EQUATE `SO_BROADCAST = &H0020 ' permit sending of broadcast msgs
%EQUATE `SO_USELOOPBACK = &H0040 ' bypass hardware when possible
%EQUATE `SO_LINGER = &H0080 ' linger on close if data present
%EQUATE `SO_OOBINLINE = &H0100 ' leave received OOB data in line
'#define SO_DONTLINGER (int)(~SO_LINGER)
'#define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR)) /* disallow local address reuse */
%EQUATE `SO_DONTLINGER = &HFFFFFF7F ' CLNG(NOT SO_LINGER)
%EQUATE `SO_EXCLUSIVEADDRUSE = &HFFFFFFFB ' CLNG(NOT S0_REUSEADDR) disallow local address reuse
'/*
' * Additional options.
' */
%EQUATE `SO_SNDBUF = &H1001 ' send buffer size
%EQUATE `SO_RCVBUF = &H1002 ' receive buffer size
%EQUATE `SO_SNDLOWAT = &H1003 ' send low-water mark
%EQUATE `SO_RCVLOWAT = &H1004 ' receive low-water mark
%EQUATE `SO_SNDTIMEO = &H1005 ' send timeout
%EQUATE `SO_RCVTIMEO = &H1006 ' receive timeout
%EQUATE `SO_ERROR = &H1007 ' get error status and clear
%EQUATE `SO_TYPE = &H1008 ' get socket type
'/*
' * WinSock 2 extension -- new options
' */
%EQUATE `SO_GROUP_ID = &H2001 ' ID of a socket group
%EQUATE `SO_GROUP_PRIORITY = &H2002 ' the relative priority within a group
%EQUATE `SO_MAX_MSG_SIZE = &H2003 ' maximum message size
%EQUATE `SO_PROTOCOL_INFO = &H2004 ' WSAPROTOCOL_INFO structure
%EQUATE `SO_PROTOCOL_INFOW = &H2005 ' WSAPROTOCOL_INFOW structure */
%EQUATE `PVD_CONFIG = &H3001 ' configuration info for service provider
%EQUATE `SO_CONDITIONAL_ACCEPT = &H3002 ' enable true conditional accept:
 ' connection is not ack-ed to the
 ' other side until conditional
 ' function returns %CF_ACCEPT
'/*
' * Structure used by kernel to pass protocol
' * information in raw sockets.
' */
' // Size = 4 bytes
TYPE sockproto WORD
 sp_family AS WORD ' u_short // address family
 sp_protocol AS WORD ' u_short // protocol
END TYPE
'/*
' * Protocol families, same as address families for now.
' */
%EQUATE `PF_UNSPEC = %AF_UNSPEC
%EQUATE `PF_UNIX = %AF_UNIX
%EQUATE `PF_INET = %AF_INET
%EQUATE `PF_IMPLINK = %AF_IMPLINK
%EQUATE `PF_PUP = %AF_PUP
%EQUATE `PF_CHAOS = %AF_CHAOS
%EQUATE `PF_NS = %AF_NS
%EQUATE `PF_IPX = %AF_IPX
%EQUATE `PF_ISO = %AF_ISO
%EQUATE `PF_OSI = %AF_OSI
%EQUATE `PF_ECMA = %AF_ECMA
%EQUATE `PF_DATAKIT = %AF_DATAKIT
%EQUATE `PF_CCITT = %AF_CCITT
%EQUATE `PF_SNA = %AF_SNA
%EQUATE `PF_DECnet = %AF_DECnet
%EQUATE `PF_DLI = %AF_DLI
%EQUATE `PF_LAT = %AF_LAT
%EQUATE `PF_HYLINK = %AF_HYLINK
%EQUATE `PF_APPLETALK = %AF_APPLETALK
%EQUATE `PF_VOICEVIEW = %AF_VOICEVIEW
%EQUATE `PF_FIREFOX = %AF_FIREFOX
%EQUATE `PF_UNKNOWN1 = %AF_UNKNOWN1
%EQUATE `PF_BAN = %AF_BAN
%EQUATE `PF_ATM = %AF_ATM
%EQUATE `PF_INET6 = %AF_INET6
'#if(_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
%EQUATE `PF_BTH = %AF_BTH
#ENDIF
'#endif //(_WIN32_WINNT >= 0x0600)
%EQUATE `PF_MAX = %AF_MAX
'/*
' * Structure used for manipulating linger option.
' */
' // ize = 4 bytes
TYPE linger WORD
 l_onoff AS WORD ' u_short // option on/off
 l_linger AS WORD ' u_short // linger time
END TYPE
'/*
' * Level number for (get/set)sockopt() to apply to socket itself.
' */
'#define SOL_SOCKET 0xffff /* options for socket level */
%EQUATE `SOL_SOCKET = &HFFFF ' options for socket level
'/*
' * Maximum queue length specifiable by listen.
' */
%EQUATE `SOMAXCONN = &H7FFFFFFF
%EQUATE `MSG_OOB = &H1 ' process out-of-band data
%EQUATE `MSG_PEEK = &H2 ' peek at incoming message
%EQUATE `MSG_DONTROUTE = &H4 ' send without using routing tables
'#if(_WIN32_WINNT >= 0x0502)
%EQUATE `MSG_WAITALL = &H8 ' /* do not complete until packet is completely filled */
'#endif //(_WIN32_WINNT >= 0x0502)
%EQUATE `MSG_PARTIAL = &H8000 ' partial send or recv for message xport
'/*
' * WinSock 2 extension -- new flags for WSASend(), WSASendTo(), WSARecv() and
' * WSARecvFrom()
' */
%EQUATE `MSG_INTERRUPT = &H10 ' send/recv in the interrupt context
%EQUATE `MSG_MAXIOVLEN = 16
'/*
' * Define constant based on rfc883, used by gethostbyxxxx() calls.
' */
%EQUATE `MAXGETHOSTSTRUCT = 1024
'/*
' * WinSock 2 extension -- bit values and indices for FD_XXX network events
' */
%EQUATE `FD_READ_BIT = 0
%EQUATE `FD_READ = 1 ' (1 << FD_READ_BIT)
%EQUATE `FD_WRITE_BIT = 1
%EQUATE `FD_WRITE = 2 ' (1 << FD_WRITE_BIT)
%EQUATE `FD_OOB_BIT = 2
%EQUATE `FD_OOB = 4 ' (1 << FD_OOB_BIT)
%EQUATE `FD_ACCEPT_BIT = 3
%EQUATE `FD_ACCEPT = 8 ' (1 << FD_ACCEPT_BIT)
%EQUATE `FD_CONNECT_BIT = 4
%EQUATE `FD_CONNECT = 16 ' (1 << FD_CONNECT_BIT)
%EQUATE `FD_CLOSE_BIT = 5
%EQUATE `FD_CLOSE = 32 ' (1 << FD_CLOSE_BIT)
%EQUATE `FD_QOS_BIT = 6
%EQUATE `FD_QOS = 64 ' (1 << FD_QOS_BIT)
%EQUATE `FD_GROUP_QOS_BIT = 7
%EQUATE `FD_GROUP_QOS = 128 ' (1 << FD_GROUP_QOS_BIT)
%EQUATE `FD_ROUTING_INTERFACE_CHANGE_BIT = 8
%EQUATE `FD_ROUTING_INTERFACE_CHANGE = 256 ' (1 << FD_ROUTING_INTERFACE_CHANGE_BIT)
%EQUATE `FD_ADDRESS_LIST_CHANGE_BIT = 9
%EQUATE `FD_ADDRESS_LIST_CHANGE = 512 ' (1 << FD_ADDRESS_LIST_CHANGE_BIT)
%EQUATE `FD_MAX_EVENTS = 10
%EQUATE `FD_ALL_EVENTS = 1024 - 1 ' ((1 << FD_MAX_EVENTS) - 1)
'/*
' * WinSock error codes are also defined in winerror.h
' * Hence the IFDEF.
' */
#IF NOT %DEF(%WSABASEERR) '----------------------------------------------------
'/*
' * All Windows Sockets error constants are biased by WSABASEERR from
' * the "normal"
' */
%EQUATE `WSABASEERR = 10000
'/*
' * Windows Sockets definitions of regular Microsoft C error constants
' */
%EQUATE `WSAEINTR = %WSABASEERR + 4
%EQUATE `WSAEBADF = %WSABASEERR + 9
%EQUATE `WSAEACCES = %WSABASEERR + 13
%EQUATE `WSAEFAULT = %WSABASEERR + 14
%EQUATE `WSAEINVAL = %WSABASEERR + 22
%EQUATE `WSAEMFILE = %WSABASEERR + 24
'/*
' * Windows Sockets definitions of regular Berkeley error constants
' */
%EQUATE `WSAEWOULDBLOCK = %WSABASEERR + 35
%EQUATE `WSAEINPROGRESS = %WSABASEERR + 36
%EQUATE `WSAEALREADY = %WSABASEERR + 37
%EQUATE `WSAENOTSOCK = %WSABASEERR + 38
%EQUATE `WSAEDESTADDRREQ = %WSABASEERR + 39
%EQUATE `WSAEMSGSIZE = %WSABASEERR + 40
%EQUATE `WSAEPROTOTYPE = %WSABASEERR + 41
%EQUATE `WSAENOPROTOOPT = %WSABASEERR + 42
%EQUATE `WSAEPROTONOSUPPORT = %WSABASEERR + 43
%EQUATE `WSAESOCKTNOSUPPORT = %WSABASEERR + 44
%EQUATE `WSAEOPNOTSUPP = %WSABASEERR + 45
%EQUATE `WSAEPFNOSUPPORT = %WSABASEERR + 46
%EQUATE `WSAEAFNOSUPPORT = %WSABASEERR + 47
%EQUATE `WSAEADDRINUSE = %WSABASEERR + 48
%EQUATE `WSAEADDRNOTAVAIL = %WSABASEERR + 49
%EQUATE `WSAENETDOWN = %WSABASEERR + 50
%EQUATE `WSAENETUNREACH = %WSABASEERR + 51
%EQUATE `WSAENETRESET = %WSABASEERR + 52
%EQUATE `WSAECONNABORTED = %WSABASEERR + 53
%EQUATE `WSAECONNRESET = %WSABASEERR + 54
%EQUATE `WSAENOBUFS = %WSABASEERR + 55
%EQUATE `WSAEISCONN = %WSABASEERR + 56
%EQUATE `WSAENOTCONN = %WSABASEERR + 57
%EQUATE `WSAESHUTDOWN = %WSABASEERR + 58
%EQUATE `WSAETOOMANYREFS = %WSABASEERR + 59
%EQUATE `WSAETIMEDOUT = %WSABASEERR + 60
%EQUATE `WSAECONNREFUSED = %WSABASEERR + 61
%EQUATE `WSAELOOP = %WSABASEERR + 62
%EQUATE `WSAENAMETOOLONG = %WSABASEERR + 63
%EQUATE `WSAEHOSTDOWN = %WSABASEERR + 64
%EQUATE `WSAEHOSTUNREACH = %WSABASEERR + 65
%EQUATE `WSAENOTEMPTY = %WSABASEERR + 66
%EQUATE `WSAEPROCLIM = %WSABASEERR + 67
%EQUATE `WSAEUSERS = %WSABASEERR + 68
%EQUATE `WSAEDQUOT = %WSABASEERR + 69
%EQUATE `WSAESTALE = %WSABASEERR + 70
%EQUATE `WSAEREMOTE = %WSABASEERR + 71
'/*
' * Extended Windows Sockets error constant definitions
' */
%EQUATE `WSASYSNOTREADY = %WSABASEERR + 91
%EQUATE `WSAVERNOTSUPPORTED = %WSABASEERR + 92
%EQUATE `WSANOTINITIALISED = %WSABASEERR + 93
%EQUATE `WSAEDISCON = %WSABASEERR + 101
%EQUATE `WSAENOMORE = %WSABASEERR + 102
%EQUATE `WSAECANCELLED = %WSABASEERR + 103
%EQUATE `WSAEINVALIDPROCTABLE = %WSABASEERR + 104
%EQUATE `WSAEINVALIDPROVIDER = %WSABASEERR + 105
%EQUATE `WSAEPROVIDERFAILEDINIT = %WSABASEERR + 106
%EQUATE `WSASYSCALLFAILURE = %WSABASEERR + 107
%EQUATE `WSASERVICE_NOT_FOUND = %WSABASEERR + 108
%EQUATE `WSATYPE_NOT_FOUND = %WSABASEERR + 109
%EQUATE `WSA_E_NO_MORE = %WSABASEERR + 110
%EQUATE `WSA_E_CANCELLED = %WSABASEERR + 111
%EQUATE `WSAEREFUSED = %WSABASEERR + 112
'/*
' * Error return codes from gethostbyname() and gethostbyaddr()
' * (when using the resolver). Note that these errors are
' * retrieved via WSAGetLastError() and must therefore follow
' * the rules for avoiding clashes with error numbers from
' * specific implementations or language run-time systems.
' * For this reason the codes are based at WSABASEERR+1001.
' * Note also that [WSA]NO_ADDRESS is defined only for
' * compatibility purposes.
' */
'/* Authoritative Answer: Host not found */
%EQUATE `WSAHOST_NOT_FOUND = %WSABASEERR+1001
'/* Non-Authoritative: Host not found, or SERVERFAIL */
%EQUATE `WSATRY_AGAIN = %WSABASEERR+1002
'/* Non-recoverable errors, FORMERR, REFUSED, NOTIMP */
%EQUATE `WSANO_RECOVERY = %WSABASEERR+1003
'/* Valid name, no data record of requested type */
%EQUATE `WSANO_DATA = %WSABASEERR+1004
'/*
' * Define QOS related error return codes
' *
' */
%EQUATE `WSA_QOS_RECEIVERS = %WSABASEERR + 1005
 ' /* at least one Reserve has arrived */
%EQUATE `WSA_QOS_SENDERS = %WSABASEERR + 1006
 ' /* at least one Path has arrived */
%EQUATE `WSA_QOS_NO_SENDERS = %WSABASEERR + 1007
 ' /* there are no senders */
%EQUATE `WSA_QOS_NO_RECEIVERS = %WSABASEERR + 1008
 ' /* there are no receivers */
%EQUATE `WSA_QOS_REQUEST_CONFIRMED = %WSABASEERR + 1009
 ' /* Reserve has been confirmed */
%EQUATE `WSA_QOS_ADMISSION_FAILURE = %WSABASEERR + 1010
 ' /* error due to lack of resources */
%EQUATE `WSA_QOS_POLICY_FAILURE = %WSABASEERR + 1011
 ' /* rejected for administrative reasons - bad credentials */
%EQUATE `WSA_QOS_BAD_STYLE = %WSABASEERR + 1012
 ' /* unknown or conflicting style */
%EQUATE `WSA_QOS_BAD_OBJECT = %WSABASEERR + 1013
 ' /* problem with some part of the filterspec or providerspecific
 ' * buffer in general */
%EQUATE `WSA_QOS_TRAFFIC_CTRL_ERROR = %WSABASEERR + 1014
 ' /* problem with some part of the flowspec */
%EQUATE `WSA_QOS_GENERIC_ERROR = %WSABASEERR + 1015
 ' /* general error */
%EQUATE `WSA_QOS_ESERVICETYPE = %WSABASEERR + 1016
 ' /* invalid service type in flowspec */
%EQUATE `WSA_QOS_EFLOWSPEC = %WSABASEERR + 1017
 ' /* invalid flowspec */
%EQUATE `WSA_QOS_EPROVSPECBUF = %WSABASEERR + 1018
 ' /* invalid provider specific buffer */
%EQUATE `WSA_QOS_EFILTERSTYLE = %WSABASEERR + 1019
 ' /* invalid filter style */
%EQUATE `WSA_QOS_EFILTERTYPE = %WSABASEERR + 1020
 ' /* invalid filter type */
%EQUATE `WSA_QOS_EFILTERCOUNT = %WSABASEERR + 1021
 ' /* incorrect number of filters */
%EQUATE `WSA_QOS_EOBJLENGTH = %WSABASEERR + 1022
 ' /* invalid object length */
%EQUATE `WSA_QOS_EFLOWCOUNT = %WSABASEERR + 1023
 ' /* incorrect number of flows */
%EQUATE `WSA_QOS_EUNKOWNPSOBJ = %WSABASEERR + 1024
 ' /* unknown object in provider specific buffer */
%EQUATE `WSA_QOS_EPOLICYOBJ = %WSABASEERR + 1025
 ' /* invalid policy object in provider specific buffer */
%EQUATE `WSA_QOS_EFLOWDESC = %WSABASEERR + 1026
 ' /* invalid flow descriptor in the list */
%EQUATE `WSA_QOS_EPSFLOWSPEC = %WSABASEERR + 1027
 ' /* inconsistent flow spec in provider specific buffer */
%EQUATE `WSA_QOS_EPSFILTERSPEC = %WSABASEERR + 1028
 ' /* invalid filter spec in provider specific buffer */
%EQUATE `WSA_QOS_ESDMODEOBJ = %WSABASEERR + 1029
 ' /* invalid shape discard mode object in provider specific buffer */
%EQUATE `WSA_QOS_ESHAPERATEOBJ = %WSABASEERR + 1030
 ' /* invalid shaping rate object in provider specific buffer */
%EQUATE `WSA_QOS_RESERVED_PETYPE = %WSABASEERR + 1031
 ' /* reserved policy element in provider specific buffer */
'/*
' * WinSock error codes are also defined in winerror.h
' * Hence the IFDEF.
' */
#ENDIF ' #IF NOT %DEF(%WSABASEERR) --------------------------------------------
'/*
' * Compatibility macros.
' */
'#define h_errno WSAGetLastError()
'#define HOST_NOT_FOUND WSAHOST_NOT_FOUND
'#define TRY_AGAIN WSATRY_AGAIN
'#define NO_RECOVERY WSANO_RECOVERY
'#define NO_DATA WSANO_DATA
'/* no address, look for MX record */
'#define WSANO_ADDRESS WSANO_DATA
'#define NO_ADDRESS WSANO_ADDRESS
%EQUATE `HOST_NOT_FOUND = %WSAHOST_NOT_FOUND
%EQUATE `TRY_AGAIN = %WSATRY_AGAIN
%EQUATE `NO_RECOVERY = %WSANO_RECOVERY
%EQUATE `NO_DATA = %WSANO_DATA
' no address, look for MX record
%EQUATE `WSANO_ADDRESS = %WSANO_DATA
%EQUATE `NO_ADDRESS = %WSANO_ADDRESS
'/*
' * Windows Sockets errors redefined as regular Berkeley error constants.
' * These are commented out in Windows NT to avoid conflicts with errno.h.
' * Use the WSA constants instead.
' */
'#if 0
'#define EWOULDBLOCK WSAEWOULDBLOCK
'#define EINPROGRESS WSAEINPROGRESS
'#define EALREADY WSAEALREADY
'#define ENOTSOCK WSAENOTSOCK
'#define EDESTADDRREQ WSAEDESTADDRREQ
'#define EMSGSIZE WSAEMSGSIZE
'#define EPROTOTYPE WSAEPROTOTYPE
'#define ENOPROTOOPT WSAENOPROTOOPT
'#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
'#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
'#define EOPNOTSUPP WSAEOPNOTSUPP
'#define EPFNOSUPPORT WSAEPFNOSUPPORT
'#define EAFNOSUPPORT WSAEAFNOSUPPORT
'#define EADDRINUSE WSAEADDRINUSE
'#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
'#define ENETDOWN WSAENETDOWN
'#define ENETUNREACH WSAENETUNREACH
'#define ENETRESET WSAENETRESET
'#define ECONNABORTED WSAECONNABORTED
'#define ECONNRESET WSAECONNRESET
'#define ENOBUFS WSAENOBUFS
'#define EISCONN WSAEISCONN
'#define ENOTCONN WSAENOTCONN
'#define ESHUTDOWN WSAESHUTDOWN
'#define ETOOMANYREFS WSAETOOMANYREFS
'#define ETIMEDOUT WSAETIMEDOUT
'#define ECONNREFUSED WSAECONNREFUSED
'#define ELOOP WSAELOOP
'#define ENAMETOOLONG WSAENAMETOOLONG
'#define EHOSTDOWN WSAEHOSTDOWN
'#define EHOSTUNREACH WSAEHOSTUNREACH
'#define ENOTEMPTY WSAENOTEMPTY
'#define EPROCLIM WSAEPROCLIM
'#define EUSERS WSAEUSERS
'#define EDQUOT WSAEDQUOT
'#define ESTALE WSAESTALE
'#define EREMOTE WSAEREMOTE
'#endif
'%EWOULDBLOCK = %WSAEWOULDBLOCK
'%EINPROGRESS = %WSAEINPROGRESS
'%EALREADY = %WSAEALREADY
'%ENOTSOCK = %WSAENOTSOCK
'%EDESTADDRREQ = %WSAEDESTADDRREQ
'%EMSGSIZE = %WSAEMSGSIZE
'%EPROTOTYPE = %WSAEPROTOTYPE
'%ENOPROTOOPT = %WSAENOPROTOOPT
'%EPROTONOSUPPORT = %WSAEPROTONOSUPPORT
'%ESOCKTNOSUPPORT = %WSAESOCKTNOSUPPORT
'%EOPNOTSUPP = %WSAEOPNOTSUPP
'%EPFNOSUPPORT = %WSAEPFNOSUPPORT
'%EAFNOSUPPORT = %WSAEAFNOSUPPORT
'%EADDRINUSE = %WSAEADDRINUSE
'%EADDRNOTAVAIL = %WSAEADDRNOTAVAIL
'%ENETDOWN = %WSAENETDOWN
'%ENETUNREACH = %WSAENETUNREACH
'%ENETRESET = %WSAENETRESET
'%ECONNABORTED = %WSAECONNABORTED
'%ECONNRESET = %WSAECONNRESET
'%ENOBUFS = %WSAENOBUFS
'%EISCONN = %WSAEISCONN
'%ENOTCONN = %WSAENOTCONN
'%ESHUTDOWN = %WSAESHUTDOWN
'%ETOOMANYREFS = %WSAETOOMANYREFS
'%ETIMEDOUT = %WSAETIMEDOUT
'%ECONNREFUSED = %WSAECONNREFUSED
'%ELOOP = %WSAELOOP
'%ENAMETOOLONG = %WSAENAMETOOLONG
'%EHOSTDOWN = %WSAEHOSTDOWN
'%EHOSTUNREACH = %WSAEHOSTUNREACH
'%ENOTEMPTY = %WSAENOTEMPTY
'%EPROCLIM = %WSAEPROCLIM
'%EUSERS = %WSAEUSERS
'%EDQUOT = %WSAEDQUOT
'%ESTALE = %WSAESTALE
'%EREMOTE = %WSAEREMOTE
'/*
' * WinSock 2 extension -- new error codes and type definition
' */
'#ifdef WIN32
'#define WSAAPI FAR PASCAL
'#define WSAEVENT HANDLE
'#define LPWSAEVENT LPHANDLE
'#define WSAOVERLAPPED OVERLAPPED
'typedef struct _OVERLAPPED * LPWSAOVERLAPPED;
' // Size = 20 bytes
TYPE WSAOVERLAPPED DWORD
 Internal AS DWORD
 InternalHigh AS DWORD
 offset AS DWORD
 OffsetHigh AS DWORD
 hEvent AS DWORD
END TYPE
%EQUATE `WSA_IO_PENDING = %ERROR_IO_PENDING
%EQUATE `WSA_IO_INCOMPLETE = %ERROR_IO_INCOMPLETE
%EQUATE `WSA_INVALID_HANDLE = %ERROR_INVALID_HANDLE
%EQUATE `WSA_INVALID_PARAMETER = %ERROR_INVALID_PARAMETER
%EQUATE `WSA_NOT_ENOUGH_MEMORY = %ERROR_NOT_ENOUGH_MEMORY
%EQUATE `WSA_OPERATION_ABORTED = %ERROR_OPERATION_ABORTED
%EQUATE `WSA_INVALID_EVENT = 0
%EQUATE `WSA_MAXIMUM_WAIT_EVENTS = %MAXIMUM_WAIT_OBJECTS
%EQUATE `WSA_WAIT_FAILED = %WAIT_FAILED
%EQUATE `WSA_WAIT_EVENT_0 = %WAIT_OBJECT_0
%EQUATE `WSA_WAIT_IO_COMPLETION = %WAIT_IO_COMPLETION
%EQUATE `WSA_WAIT_TIMEOUT = %WAIT_TIMEOUT
%EQUATE `WSA_INFINITE = %INFINITE
'#else /* WIN16 */
'#define WSAAPI FAR PASCAL
'typedef DWORD WSAEVENT, FAR * LPWSAEVENT;
'typedef struct _WSAOVERLAPPED {
' DWORD Internal;
' DWORD InternalHigh;
' DWORD Offset;
' DWORD OffsetHigh;
' WSAEVENT hEvent;
'} WSAOVERLAPPED, FAR * LPWSAOVERLAPPED;
'#define WSA_IO_PENDING (WSAEWOULDBLOCK)
'#define WSA_IO_INCOMPLETE (WSAEWOULDBLOCK)
'#define WSA_INVALID_HANDLE (WSAENOTSOCK)
'#define WSA_INVALID_PARAMETER (WSAEINVAL)
'#define WSA_NOT_ENOUGH_MEMORY (WSAENOBUFS)
'#define WSA_OPERATION_ABORTED (WSAEINTR)
'#define WSA_INVALID_EVENT ((WSAEVENT)NULL)
'#define WSA_MAXIMUM_WAIT_EVENTS (MAXIMUM_WAIT_OBJECTS)
'#define WSA_WAIT_FAILED ((DWORD)-1L)
'#define WSA_WAIT_EVENT_0 ((DWORD)0)
'#define WSA_WAIT_TIMEOUT ((DWORD)0x102L)
'#define WSA_INFINITE ((DWORD)-1L)
'#endif /* WIN32 */
'/*
' * Include qos.h to pull in FLOWSPEC and related definitions
' */
#INCLUDE ONCE "Legacy/Network/Qos.inc"
' // Size = 72 bytes
TYPE QOS DWORD
 SendingFlowspec AS FLOWSPEC ' FLOWSPEC // the flow spec for data sending
 ReceivingFlowspec AS FLOWSPEC ' FLOWSPEC // the flow spec for data receiving
 ProviderSpecific AS WSABUF ' WSABUF // additional provider-specific stuff
END TYPE
'/*
' * WinSock 2 extension -- manifest constants for return values of the condition function
' */
%EQUATE `CF_ACCEPT = &H0000
%EQUATE `CF_REJECT = &H0001
%EQUATE `CF_DEFER = &H0002
'/*
' * WinSock 2 extension -- manifest constants for shutdown()
' */
%EQUATE `SD_RECEIVE = &H00
%EQUATE `SD_SEND = &H01
%EQUATE `SD_BOTH = &H02
'/*
' * WinSock 2 extension -- data type and manifest constants for socket groups
' */
'typedef unsigned int GROUP;
%EQUATE `SG_UNCONSTRAINED_GROUP = &H01
%EQUATE `SG_CONSTRAINED_GROUP = &H02
'/*
' * WinSock 2 extension -- data type for WSAEnumNetworkEvents()
' */
' // Size = 44 bytes
TYPE WSANETWORKEVENTS DWORD
 lNetworkEvents AS LONG
 iErrorCode(%FD_MAX_EVENTS - 1) AS LONG
END TYPE
'/*
' * WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
' * manifest constants
' */
'#ifndef GUID_DEFINED
'#include <guiddef.h>
'#endif /* GUID_DEFINED */
#IF NOT %DEF(%GUID_DEFINED)
#INCLUDE ONCE "Legacy/UI/Guiddef.inc"
#ENDIF
%EQUATE `MAX_PROTOCOL_CHAIN = 7
%EQUATE `BASE_PROTOCOL = 1
%EQUATE `LAYERED_PROTOCOL = 0
' // Size = 32 bytes
TYPE WSAPROTOCOLCHAIN DWORD
 ChainLen AS LONG
 ChainEntries(%MAX_PROTOCOL_CHAIN - 1) AS DWORD ' DWORD // a list of dwCatalogEntryIds
END TYPE
%EQUATE `WSAPROTOCOL_LEN = 255
' // Size = 372 bytes
TYPE WSAPROTOCOL_INFOA DWORD
 dwServiceFlags1 AS DWORD
 dwServiceFlags2 AS DWORD
 dwServiceFlags3 AS DWORD
 dwServiceFlags4 AS DWORD
 dwProviderFlags AS DWORD
 ProviderId AS GUID ' GUID
 dwCatalogEntryId AS DWORD
 ProtocolChain AS WSAPROTOCOLCHAIN
 iVersion AS LONG
 iAddressFamily AS LONG
 iMaxSockAddr AS LONG
 iMinSockAddr AS LONG
 iSocketType AS LONG
 iProtocol AS LONG
 iProtocolMaxOffset AS LONG
 iNetworkByteOrder AS LONG
 iSecurityScheme AS LONG
 dwMessageSize AS DWORD
 dwProviderReserved AS DWORD
 szProtocol AS ASCIIZ * (%WSAPROTOCOL_LEN + 1) ' CHAR
END TYPE
' // Size = 628 bytes
TYPE WSAPROTOCOL_INFOW DWORD
 dwServiceFlags1 AS DWORD
 dwServiceFlags2 AS DWORD
 dwServiceFlags3 AS DWORD
 dwServiceFlags4 AS DWORD
 dwProviderFlags AS DWORD
 ProviderId AS GUID ' GUID
 dwCatalogEntryId AS DWORD
 ProtocolChain AS WSAPROTOCOLCHAIN
 iVersion AS LONG
 iAddressFamily AS LONG
 iMaxSockAddr AS LONG
 iMinSockAddr AS LONG
 iSocketType AS LONG
 iProtocol AS LONG
 iProtocolMaxOffset AS LONG
 iNetworkByteOrder AS LONG
 iSecurityScheme AS LONG
 dwMessageSize AS DWORD
 dwProviderReserved AS DWORD
 szProtocol AS WSTRINGZ * %WSAPROTOCOL_LEN + 1 ' WCHAR
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSAPROTOCOL_INFO = WSAPROTOCOL_INFOAW
#ELSE
 MACRO WSAPROTOCOL_INFO = WSAPROTOCOL_INFOAA
#ENDIF
'/* Flag bit definitions for dwProviderFlags */
%EQUATE `PFL_MULTIPLE_PROTO_ENTRIES = &H00000001
%EQUATE `PFL_RECOMMENDED_PROTO_ENTRY = &H00000002
%EQUATE `PFL_HIDDEN = &H00000004
%EQUATE `PFL_MATCHES_PROTOCOL_ZERO = &H00000008
%EQUATE `PFL_NETWORKDIRECT_PROVIDER = &H00000010
'/* Flag bit definitions for dwServiceFlags1 */
%EQUATE `XP1_CONNECTIONLESS = &H00000001
%EQUATE `XP1_GUARANTEED_DELIVERY = &H00000002
%EQUATE `XP1_GUARANTEED_ORDER = &H00000004
%EQUATE `XP1_MESSAGE_ORIENTED = &H00000008
%EQUATE `XP1_PSEUDO_STREAM = &H00000010
%EQUATE `XP1_GRACEFUL_CLOSE = &H00000020
%EQUATE `XP1_EXPEDITED_DATA = &H00000040
%EQUATE `XP1_CONNECT_DATA = &H00000080
%EQUATE `XP1_DISCONNECT_DATA = &H00000100
%EQUATE `XP1_SUPPORT_BROADCAST = &H00000200
%EQUATE `XP1_SUPPORT_MULTIPOINT = &H00000400
%EQUATE `XP1_MULTIPOINT_CONTROL_PLANE = &H00000800
%EQUATE `XP1_MULTIPOINT_DATA_PLANE = &H00001000
%EQUATE `XP1_QOS_SUPPORTED = &H00002000
%EQUATE `XP1_INTERRUPT = &H00004000
%EQUATE `XP1_UNI_SEND = &H00008000
%EQUATE `XP1_UNI_RECV = &H00010000
%EQUATE `XP1_IFS_HANDLES = &H00020000
%EQUATE `XP1_PARTIAL_MESSAGE = &H00040000
%EQUATE `XP1_SAN_SUPPORT_SDP = &H00080000
%EQUATE `BIGENDIAN = &H0000&
%EQUATE `LITTLEENDIAN = &H0001&
%EQUATE `SECURITY_PROTOCOL_NONE = &H0000&
'/*
' * WinSock 2 extension -- manifest constants for WSAJoinLeaf()
' */
%EQUATE `JL_SENDER_ONLY = &H01
%EQUATE `JL_RECEIVER_ONLY = &H02
%EQUATE `JL_BOTH = &H04
'/*
' * WinSock 2 extension -- manifest constants for WSASocket()
' */
%EQUATE `WSA_FLAG_OVERLAPPED = &H01
%EQUATE `WSA_FLAG_MULTIPOINT_C_ROOT = &H02
%EQUATE `WSA_FLAG_MULTIPOINT_C_LEAF = &H04
%EQUATE `WSA_FLAG_MULTIPOINT_D_ROOT = &H08
%EQUATE `WSA_FLAG_MULTIPOINT_D_LEAF = &H10
%EQUATE `WSA_FLAG_ACCESS_SYSTEM_SECURITY = &H40
'/*
' * WinSock 2 extensions -- data types for the condition function in
' * WSAAccept() and overlapped I/O completion routine.
' */
'typedef
'int
'(CALLBACK * LPCONDITIONPROC)(
' IN LPWSABUF lpCallerId,
' IN LPWSABUF lpCallerData,
' IN OUT LPQOS lpSQOS,
' IN OUT LPQOS lpGQOS,
' IN LPWSABUF lpCalleeId,
' IN LPWSABUF lpCalleeData,
' OUT GROUP FAR * g,
' IN DWORD_PTR dwCallbackData
' );
'FUNCTION CONDITIONPROC ( ' BYREF lpCallerId AS WSABUF,
' BYREF lpCallerData AS WSABUF,
' BYREF lpSQOS AS QOS,
' BYREF lpGQOS AS QOS,
' BYREF lpCalleeId AS WSABUF,
' BYREF lpCalleeData AS WSABUF,
' BYREF g AS DWORD,
' BYVAL dwCallbackData AS DWORD
' ) AS LONG
'typedef
'void
'(CALLBACK * LPWSAOVERLAPPED_COMPLETION_ROUTINE)(
' IN DWORD dwError,
' IN DWORD cbTransferred,
' IN LPWSAOVERLAPPED lpOverlapped,
' IN DWORD dwFlags
' );
'SUB WSAOVERLAPPED_COMPLETION_ROUTINE ( ' BYVAL dwError AS DWORD,
' BYVAL cbTransferred AS DWORD, ' IN DWORD cbTransferred
' BYREF lpOverlapped AS WSAOVERLAPPED,
' BYVAL dwFlags AS DWORD
' )
'#if(_WIN32_WINNT >= 0x0501)
'/*
' * WinSock 2 extension -- manifest constants and associated structures
' * for WSANSPIoctl()
' */
'#define SIO_NSP_NOTIFY_CHANGE _WSAIOW(IOC_WS2,25)
%EQUATE `SIO_NSP_NOTIFY_CHANGE = &H88000019
' WSACOMPLETIONTYPE enum
%EQUATE `NSP_NOTIFY_IMMEDIATELY = 0
%EQUATE `NSP_NOTIFY_HWND = 1
%EQUATE `NSP_NOTIFY_EVENT = 2
%EQUATE `NSP_NOTIFY_PORT = 3
%EQUATE `NSP_NOTIFY_APC = 4
'typedef struct _WSACOMPLETION {
' WSACOMPLETIONTYPE Type;
' union {
' struct {
' HWND hWnd;
' UINT uMsg;
' WPARAM context;
' } WindowMessage;
' struct {
' LPWSAOVERLAPPED lpOverlapped;
' } Event;
' struct {
' LPWSAOVERLAPPED lpOverlapped;
' LPWSAOVERLAPPED_COMPLETION_ROUTINE lpfnCompletionProc;
' } Apc;
' struct {
' LPWSAOVERLAPPED lpOverlapped;
' HANDLE hPort;
' ULONG_PTR Key;
' } Port;
' } Parameters;
'} WSACOMPLETION, *PWSACOMPLETION, FAR *LPWSACOMPLETION;
' // Size = 12 bytes
TYPE WSACOMPLETION_WindowMessage DWORD
 hWnd AS DWORD
 uMsg AS DWORD
 context AS DWORD
END TYPE
' // Size = 4 bytes
TYPE WSACOMPLETION_Event DWORD
 lpOverlapped AS WSAOVERLAPPED PTR
END TYPE
' // Size = 8 bytes
TYPE WSACOMPLETION_Apc DWORD
 lpOverlapped AS WSAOVERLAPPED PTR
 lpfnCompletionProc AS DWORD
END TYPE
' // Size = 12 bytes
TYPE WSACOMPLETION_Port DWORD
 lpOverlapped AS WSAOVERLAPPED PTR
 hPort AS DWORD
 Key AS DWORD
END TYPE
' // Size = 12 bytes
UNION WSACOMPLETION_Parameters DWORD
 WindowMessage AS WSACOMPLETION_WindowMessage
 Event AS WSACOMPLETION_Event
 Apc AS WSACOMPLETION_Apc
 Port AS WSACOMPLETION_Port
END UNION
' // Size = 16 bytes
TYPE WSACOMPLETION DWORD
 Type AS LONG
 Parameters AS WSACOMPLETION_Parameters
END TYPE
'#endif //(_WIN32_WINNT >= 0x0501)
'/*
' * WinSock 2 extension -- manifest constants for SIO_TRANSLATE_HANDLE ioctl
' */
%EQUATE `TH_NETDEV = &H00000001
%EQUATE `TH_TAPI = &H00000002
'/*
' * Microsoft Windows Extended data types required for the functions to
' * convert back and forth between binary and string forms of
' * addresses.
' */
'typedef struct sockaddr SOCKADDR;
'typedef struct sockaddr *PSOCKADDR;
'typedef struct sockaddr FAR *LPSOCKADDR;
'typedef struct sockaddr_storage SOCKADDR_STORAGE;
'typedef struct sockaddr_storage *PSOCKADDR_STORAGE;
'typedef struct sockaddr_storage FAR *LPSOCKADDR_STORAGE;
'/*
' * Manifest constants and type definitions related to name resolution and
' * registration (RNR) API
' */
'#ifndef _tagBLOB_DEFINED
'#define _tagBLOB_DEFINED
'#define _BLOB_DEFINED
'#define _LPBLOB_DEFINED
'typedef struct _BLOB {
' ULONG cbSize ;
'#ifdef MIDL_PASS
' [size_is(cbSize)] BYTE *pBlobData;
'#else /* MIDL_PASS */
' BYTE *pBlobData ;
'#endif /* MIDL_PASS */
'} BLOB, *LPBLOB ;
'#endif
#IF NOT %DEF(%BLOB_DEFINED)
%EQUATE `BLOB_DEFINED = 1
' // Size = 8 bytes
TYPE BLOB DWORD
 cbSize AS DWORD
 pBlobData AS BYTE PTR
END TYPE
#ENDIF
'/*
' * Service Install Flags
' */
%EQUATE `SERVICE_MULTIPLE = &H00000001
'/*
' *& Name Spaces
' */
%EQUATE `NS_ALL = 0
%EQUATE `NS_SAP = 1
%EQUATE `NS_NDS = 2
%EQUATE `NS_PEER_BROWSE = 3
%EQUATE `NS_SLP = 5
%EQUATE `NS_DHCP = 6
%EQUATE `NS_TCPIP_LOCAL = 10
%EQUATE `NS_TCPIP_HOSTS = 11
%EQUATE `NS_DNS = 12
%EQUATE `NS_NETBT = 13
%EQUATE `NS_WINS = 14
'#if(_WIN32_WINNT >= 0x0501)
%EQUATE `NS_NLA = 15 ' /* Network Location Awareness */
'#endif //(_WIN32_WINNT >= 0x0501)
'#if(_WIN32_WINNT >= 0x0600)
%EQUATE `NS_BTH = 16 ' /* Bluetooth SDP Namespace */
'#endif //(_WIN32_WINNT >= 0x0600)
%EQUATE `NS_LOCALNAME = 19 ' /* Windows Live */
%EQUATE `NS_NBP = 20
%EQUATE `NS_MS = 30
%EQUATE `NS_STDA = 31
%EQUATE `NS_NTDS = 32
'#if(_WIN32_WINNT >= 0x0600)
%EQUATE `NS_EMAIL = 37
%EQUATE `NS_PNRPNAME = 38
%EQUATE `NS_PNRPCLOUD = 39
'#endif //(_WIN32_WINNT >= 0x0600)
%EQUATE `NS_X500 = 40
%EQUATE `NS_NIS = 41
%EQUATE `NS_NISPLUS = 42
%EQUATE `NS_WRQ = 50
%EQUATE `NS_NETDES = 60 ' Network Designers Limited
'/*
' * Resolution flags for WSAGetAddressByName().
' * Note these are also used by the 1.1 API GetAddressByName, so
' * leave them around.
' */
%EQUATE `RES_UNUSED_1 = &H00000001
%EQUATE `RES_FLUSH_CACHE = &H00000002
#IF NOT %DEF(%RES_SERVICE)
%EQUATE `RES_SERVICE = &H00000004
#ENDIF
'/*
' * Well known value names for Service Types
' */
$SERVICE_TYPE_VALUE_IPXPORTA = "IpxSocket"
$$SERVICE_TYPE_VALUE_IPXPORTW = "IpxSocket"$$
$SERVICE_TYPE_VALUE_SAPIDA = "SapId"
$$SERVICE_TYPE_VALUE_SAPIDW = "SapId"$$
$SERVICE_TYPE_VALUE_TCPPORTA = "TcpPort"
$$SERVICE_TYPE_VALUE_TCPPORTW = "TcpPort"$$
$SERVICE_TYPE_VALUE_UDPPORTA = "UdpPort"
$$SERVICE_TYPE_VALUE_UDPPORTW = "UdpPort"$$
$SERVICE_TYPE_VALUE_OBJECTIDA = "ObjectId"
$$SERVICE_TYPE_VALUE_OBJECTIDW = "ObjectId"$$
'/*
' * SockAddr Information
' */
#IF NOT %DEF(%SOCKET_ADDRESS_DEFINED)
%EQUATE `SOCKET_ADDRESS_DEFINED = 1
' // Size = 8 bytes
TYPE SOCKET_ADDRESS DWORD
 lpSocaddr AS SOCKADDR PTR ' LPSOCKADDR lpSockaddr
 iSockaddrLength AS LONG
END TYPE
#ENDIF
'/*
' * Address Family/Protocol Tuples
' */
' // Size = 8 bytes
TYPE AFPROTOCOLS DWORD
 iAddressFamily AS LONG
 iProtocol AS LONG
END TYPE
'/*
' * Client Query API Typedefs
' */
'/*
' * The comparators
' */
' WSAECOMPARATOR enum
%EQUATE `COMP_EQUAL = 0
%EQUATE `COMP_NOTLESS = 1
' // Size = 8 bytes
TYPE WSAVERSION DWORD
 dwVersion AS DWORD
 ecHow AS LONG ' WSAECOMPARATOR
END TYPE
' // Size = 60 bytes
TYPE WSAQUERYSETA DWORD
 dwSize AS DWORD
 lpszServiceInstanceName AS ASCIIZ PTR
 lpServiceClassId AS GUID PTR
 lpVersion AS WSAVERSION PTR
 lpszComment AS ASCIIZ PTR
 dwNameSpace AS DWORD
 lpNSProviderId AS GUID PTR
 lpszContext AS ASCIIZ PTR
 dwNumberOfProtocols AS DWORD
 lpafpProtocols AS AFPROTOCOLS PTR
 lpszQueryString AS ASCIIZ PTR
 dwNumberOfCsAddrs AS DWORD
 lpcsaBuffer AS CSADDR_INFO PTR ' LPCSADDR_INFO
 dwOutputFlags AS DWORD
 lpBlob AS BLOB PTR
END TYPE
' // Size = 60 bytes
TYPE WSAQUERYSETW DWORD
 dwSize AS DWORD
 lpszServiceInstanceName AS WSTRINGZ PTR
 lpServiceClassId AS GUID PTR
 lpVersion AS WSAVERSION PTR
 lpszComment AS WSTRINGZ PTR
 dwNameSpace AS DWORD
 lpNSProviderId AS GUID PTR
 lpszContext AS WSTRINGZ PTR
 dwNumberOfProtocols AS DWORD
 lpafpProtocols AS AFPROTOCOLS PTR
 lpszQueryString AS WSTRINGZ PTR
 dwNumberOfCsAddrs AS DWORD
 lpcsaBuffer AS CSADDR_INFO PTR ' LPCSADDR_INFO
 dwOutputFlags AS DWORD
 lpBlob AS BLOB PTR
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSAQUERYSET = WSAQUERYSETW
#ELSE
 MACRO WSAQUERYSET = WSAQUERYSETA
#ENDIF
' // Size = 56 bytes
TYPE WSAQUERYSET2A DWORD
 dwSize AS DWORD
 lpszServiceInstanceName AS ASCIIZ PTR
 lpVersion AS WSAVERSION PTR
 lpszComment AS ASCIIZ PTR
 dwNameSpace AS DWORD
 lpNSProviderId AS GUID PTR
 lpszContext AS ASCIIZ PTR
 dwNumberOfProtocols AS DWORD
 lpafpProtocols AS AFPROTOCOLS PTR
 lpszQueryString AS ASCIIZ PTR
 dwNumberOfCsAddrs AS DWORD
 lpcsaBuffer AS CSADDR_INFO PTR ' LPCSADDR_INFO
 dwOutputFlags AS DWORD
 lpBlob AS BLOB PTR
END TYPE
' // Size = 56 bytes
TYPE WSAQUERYSET2W DWORD
 dwSize AS DWORD
 lpszServiceInstanceName AS WSTRINGZ PTR
 lpVersion AS WSAVERSION PTR
 lpszComment AS WSTRINGZ PTR
 dwNameSpace AS DWORD
 lpNSProviderId AS GUID PTR
 lpszContext AS WSTRINGZ PTR
 dwNumberOfProtocols AS DWORD
 lpafpProtocols AS AFPROTOCOLS PTR
 lpszQueryString AS WSTRINGZ PTR
 dwNumberOfCsAddrs AS DWORD
 lpcsaBuffer AS CSADDR_INFO PTR ' LPCSADDR_INFO
 dwOutputFlags AS DWORD
 lpBlob AS BLOB PTR
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSAQUERYSET2 = WSAQUERYSET2W
#ELSE
 MACRO WSAQUERYSET2 = WSAQUERYSET2A
#ENDIF
%EQUATE `LUP_DEEP = &H0001
%EQUATE `LUP_CONTAINERS = &H0002
%EQUATE `LUP_NOCONTAINERS = &H0004
%EQUATE `LUP_NEAREST = &H0008
%EQUATE `LUP_RETURN_NAME = &H0010
%EQUATE `LUP_RETURN_TYPE = &H0020
%EQUATE `LUP_RETURN_VERSION = &H0040
%EQUATE `LUP_RETURN_COMMENT = &H0080
%EQUATE `LUP_RETURN_ADDR = &H0100
%EQUATE `LUP_RETURN_BLOB = &H0200
%EQUATE `LUP_RETURN_ALIASES = &H0400
%EQUATE `LUP_RETURN_QUERY_STRING = &H0800
%EQUATE `LUP_RETURN_ALL = &H0FF0
%EQUATE `LUP_RES_SERVICE = &H8000
%EQUATE `LUP_FLUSHCACHE = &H1000
%EQUATE `LUP_FLUSHPREVIOUS = &H2000
%EQUATE `LUP_NON_AUTHORITATIVE = &H4000
%EQUATE `LUP_SECURE = &H8000
%EQUATE `LUP_RETURN_PREFERRED_NAMES = &H10000
%EQUATE `LUP_ADDRCONFIG = &H00100000
%EQUATE `LUP_DUAL_ADDR = &H00200000
%EQUATE `LUP_FILESERVER = &H00400000
'/*
' * Return flags
' */
%EQUATE `RESULT_IS_ALIAS = &H0001
'#if(_WIN32_WINNT >= 0x0501)
%EQUATE `RESULT_IS_ADDED = &H0010
%EQUATE `RESULT_IS_CHANGED = &H0020
%EQUATE `RESULT_IS_DELETED = &H0040
'#endif //(_WIN32_WINNT >= 0x0501)
'/*
' * Service Address Registration and Deregistration Data Types.
' */
' WSAESETSERVICEOP enum
%EQUATE `RNRSERVICE_REGISTER = 0
%EQUATE `RNRSERVICE_DEREGISTER = 1
%EQUATE `RNRSERVICE_DELETE = 2
'/*
' * Service Installation/Removal Data Types.
' */
' // Size = 20 bytes
TYPE WSANSCLASSINFOA DWORD
 lpszName AS ASCIIZ PTR
 dwNameSpace AS DWORD
 dwValueType AS DWORD
 dwValueSize AS DWORD
 lpValue AS DWORD
END TYPE
' // Size = 20 bytes
TYPE WSANSCLASSINFOW DWORD
 lpszName AS WSTRINGZ PTR
 dwNameSpace AS DWORD
 dwValueType AS DWORD
 dwValueSize AS DWORD
 lpValue AS DWORD
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSANSCLASSINFO = WSANSCLASSINFOW
#ELSE
 MACRO WSANSCLASSINFO = WSANSCLASSINFOA
#ENDIF
' // Size = 16 bytes
TYPE WSASERVICECLASSINFOA DWORD
 lpServiceClassId AS GUID PTR
 lpszServiceClassName AS ASCIIZ PTR
 dwCount AS DWORD
 lpClassInfos AS WSANSCLASSINFO PTR
END TYPE
' // Size = 16 bytes
TYPE WSASERVICECLASSINFOW DWORD
 lpServiceClassId AS GUID PTR
 lpszServiceClassName AS WSTRINGZ PTR
 dwCount AS DWORD
 lpClassInfos AS WSANSCLASSINFOW PTR
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSASERVICECLASSINFO = WSASERVICECLASSINFOW
#ELSE
 MACRO WSASERVICECLASSINFO = WSASERVICECLASSINFOA
#ENDIF
' // Size = 32 bytes
TYPE WSANAMESPACE_INFOA DWORD
 NSProviderId AS GUID ' GUID
 dwNameSpace AS DWORD
 fActive AS LONG
 dwVersion AS DWORD
 lpszIdentifier AS ASCIIZ PTR
END TYPE
' // Size = 32 bytes
TYPE WSANAMESPACE_INFOW DWORD
 NSProviderId AS GUID ' GUID
 dwNameSpace AS DWORD
 fActive AS LONG
 dwVersion AS DWORD
 lpszIdentifier AS WSTRINGZ PTR
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSANAMESPACE_INFO = WSANAMESPACE_INFOW
#ELSE
 MACRO WSANAMESPACE_INFO = WSANAMESPACE_INFOA
#ENDIF
' // Size = 40 bytes
TYPE WSANAMESPACE_INFOEXA DWORD
 NSProviderId AS GUID ' GUID
 dwNameSpace AS DWORD
 fActive AS LONG
 dwVersion AS DWORD
 lpszIdentifier AS ASCIIZ PTR
 ProviderSpecific AS BLOB ' BLOB
END TYPE
' // Size = 40 bytes
TYPE WSANAMESPACE_INFOEXW DWORD
 NSProviderId AS GUID ' GUID
 dwNameSpace AS DWORD
 fActive AS LONG
 dwVersion AS DWORD
 lpszIdentifier AS WSTRINGZ PTR
 ProviderSpecific AS BLOB ' BLOB
END TYPE
#IF %DEF(%UNICODE)
 MACRO WSANAMESPACE_INFOEX = WSANAMESPACE_INFOEXW
#ELSE
 MACRO WSANAMESPACE_INFOEX = WSANAMESPACE_INFOEXA
#ENDIF
'#if(_WIN32_WINNT >= 0x0600)
'/* Event flag definitions for WSAPoll(). */
%EQUATE `POLLRDNORM = &H0100
%EQUATE `POLLRDBAND = &H0200
%EQUATE `POLLIN = %POLLRDNORM OR %POLLRDBAND
%EQUATE `POLLPRI = &H0400
%EQUATE `POLLWRNORM = &H0010
%EQUATE `POLLOUT = %POLLWRNORM
%EQUATE `POLLWRBAND = &H0020
%EQUATE `POLLERR = &H0001
%EQUATE `POLLHUP = &H0002
%EQUATE `POLLNVAL = &H0004
' // Size = 8 bytes
TYPE WSAPOLLFD DWORD FILL
 fd AS DWORD ' SOCKET
 events AS INTEGER ' SHORT
 revents AS INTEGER ' SHORT
END TYPE
'#endif // (_WIN32_WINNT >= 0x0600)
'/* Socket function prototypes */
'#IF (%INCL_WINSOCK_API_PROTOTYPES) '-------------------------------------------
DECLARE FUNCTION aaccept LIB "ws2_32.dll" ALIAS "accept" ( BYVAL s AS QUAD , BYREF addr AS sockaddr_in , BYREF addrlen AS LONG ) AS QUAD ' SOCKET
DECLARE FUNCTION bind LIB "ws2_32.dll" ALIAS "bind" ( BYVAL s AS QUAD , BYREF addr AS sockaddr_in , BYVAL namelen AS LONG ) AS LONG ' int
DECLARE FUNCTION closesocket LIB "ws2_32.dll" ALIAS "closesocket" ( BYVAL s AS QUAD ) AS LONG ' int
DECLARE FUNCTION cconnect LIB "ws2_32.dll" ALIAS "connect" ( BYVAL s AS QUAD , BYREF name AS sockaddr_in , BYVAL namelen AS LONG ) AS LONG ' int
DECLARE FUNCTION ioctlsocket LIB "ws2_32.dll" ALIAS "ioctlsocket" ( BYVAL s AS QUAD , BYVAL cmd AS LONG , BYREF argp AS QUAD ) AS LONG ' int
DECLARE FUNCTION getpeername LIB "ws2_32.dll" ALIAS "getpeername" ( BYVAL s AS QUAD , BYREF name AS sockaddr_in , BYREF namelen AS LONG ) AS LONG ' int
DECLARE FUNCTION getsockname LIB "ws2_32.dll" ALIAS "getsockname" ( BYVAL s AS QUAD , BYREF name AS sockaddr_in , BYREF namelen AS LONG ) AS LONG ' int
DECLARE FUNCTION getsockopt LIB "ws2_32.dll" ALIAS "getsockopt" ( BYVAL s AS QUAD , BYVAL level AS LONG , BYVAL optname AS LONG , BYREF optval AS ANY , BYREF optlen AS LONG ) AS LONG ' int
DECLARE FUNCTION htonl LIB "ws2_32.dll" ALIAS "htonl" ( BYVAL hostlong AS QUAD ) AS QUAD ' u_long
DECLARE FUNCTION htons LIB "ws2_32.dll" ALIAS "htons" ( BYVAL hostshort AS WORD ) AS WORD ' u_short
DECLARE FUNCTION inet_addr LIB "ws2_32.dll" ALIAS "inet_addr" ( BYREF cp AS ASCIIZ ) AS QUAD ' unsigned long
DECLARE FUNCTION inet_ntoa LIB "ws2_32.dll" ALIAS "inet_ntoa" ( BYVAL in_ AS in_addr ) AS QUAD ' char FAR*
DECLARE FUNCTION listen LIB "ws2_32.dll" ALIAS "listen" ( BYVAL s AS QUAD , BYVAL backlog AS LONG ) AS LONG ' int
DECLARE FUNCTION ntohl LIB "ws2_32.dll" ALIAS "ntohl" ( BYVAL netlong AS QUAD ) AS QUAD ' u_long
DECLARE FUNCTION ntohs LIB "ws2_32.dll" ALIAS "ntohs" ( BYVAL netshort AS WORD ) AS WORD ' u_short
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION rrecv LIB "ws2_32.dll" ALIAS "recv" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG, BYVAL flags AS LONG ) AS LONG
#ELSE
DECLARE FUNCTION rrecv LIB "ws2_32.dll" ALIAS "recv" ( BYVAL s AS QUAD , BYREF buf AS ANY , BYVAL len AS LONG , BYVAL flags AS LONG ) AS LONG ' int
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION recvfrom LIB "ws2_32.dll" ALIAS "recvfrom" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG, BYVAL flags AS LONG, saFrom AS SOCKADDR, fromlen AS LONG ) AS LONG
#ELSE
DECLARE FUNCTION recvfrom LIB "ws2_32.dll" ALIAS "recvfrom" ( BYVAL s AS QUAD , BYREF buf AS ANY , BYVAL len AS LONG , BYVAL flags AS LONG , BYREF from AS sockaddr_in , BYREF fromlen AS LONG ) AS LONG ' int
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION sselect LIB "ws2_32.dll" ALIAS "select" ( BYVAL nfds AS LONG, readfds AS fd_set, writefds AS fd_set, exceptfds AS FD_SET, tymeout AS timeval ) AS LONG
#ELSE
DECLARE FUNCTION sselect LIB "ws2_32.dll" ALIAS "select" ( BYVAL nfds AS LONG , BYREF readfds AS fd_setstruc , BYREF writefds AS fd_setstruc , BYREF exceptfds AS fd_setstruc , BYREF timeout AS TIMEVAL ) AS LONG ' int
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ssend LIB "ws2_32.dll" ALIAS "send" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG, BYVAL flags AS LONG ) AS LONG
#ELSE
DECLARE FUNCTION ssend LIB "ws2_32.dll" ALIAS "send" ( BYVAL s AS QUAD , BYREF buf AS ANY , BYVAL len AS LONG , BYVAL flags AS LONG ) AS LONG ' int
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION sendto LIB "ws2_32.dll" ALIAS "sendto" ( BYVAL s AS QUAD, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG, BYVAL flags AS LONG, to_addr AS SOCKADDR, BYVAL tolen AS LONG ) AS LONG
#ELSE
DECLARE FUNCTION sendto LIB "ws2_32.dll" ALIAS "sendto" ( BYVAL s AS QUAD , BYREF buf AS ANY , BYVAL len AS LONG , BYVAL flags AS LONG , BYREF to AS sockaddr_in , BYVAL tolen AS LONG ) AS LONG ' int
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION setsockopt LIB "ws2_32.dll" ALIAS "setsockopt" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL level AS LONG, BYVAL optname AS LONG, BYVAL optval AS BYTE PTR, BYVAL optlen AS LONG ) AS LONG
#ELSE
DECLARE FUNCTION setsockopt LIB "ws2_32.dll" ALIAS "setsockopt" ( BYVAL s AS QUAD , BYVAL level AS LONG , BYVAL optname AS LONG , BYREF optval AS ANY , BYVAL optlen AS LONG ) AS LONG ' int
#ENDIF
DECLARE FUNCTION shutdown LIB "ws2_32.dll" ALIAS "shutdown" ( BYVAL s AS QUAD , BYVAL how AS LONG ) AS LONG ' int
DECLARE FUNCTION socket LIB "ws2_32.dll" ALIAS "socket" ( BYVAL af AS QUAD , BYVAL type AS LONG , BYVAL protocol AS LONG ) AS QUAD ' SOCKET
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION gethostbyaddr LIB "ws2_32.dll" ALIAS "gethostbyaddr" ( BYVAL saAddr AS BYTE PTR, BYVAL addr_len AS LONG, BYVAL addr_type AS LONG ) AS QUAD ' hostent PTR
#ELSE
DECLARE FUNCTION gethostbyaddr LIB "ws2_32.dll" ALIAS "gethostbyaddr" ( BYREF addr AS ANY , BYVAL len AS LONG , BYVAL type AS LONG ) AS QUAD ' struct hostent FAR *
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION gethostbyname LIB "ws2_32.dll" ALIAS "gethostbyname" ( hname AS ASCIIZ ) AS QUAD ' hostent PTR
#ELSE
DECLARE FUNCTION gethostbyname LIB "ws2_32.dll" ALIAS "gethostbyname" ( BYREF name AS ASCIIZ ) AS LONG ' struct hostent FAR *
#ENDIF
DECLARE FUNCTION gethostname LIB "ws2_32.dll" ALIAS "gethostname" ( BYREF name AS ASCIIZ , BYVAL namelen AS LONG ) AS LONG ' int
DECLARE FUNCTION getservbyport LIB "ws2_32.dll" ALIAS "getservbyport" ( BYVAL port AS LONG , BYREF proto AS ASCIIZ ) AS QUAD ' struct servent FAR *
DECLARE FUNCTION getservbyname LIB "ws2_32.dll" ALIAS "getservbyname" ( BYREF name AS ASCIIZ , BYREF proto AS ASCIIZ ) AS QUAD ' struct servent FAR *
DECLARE FUNCTION getprotobynumber LIB "ws2_32.dll" ALIAS "getprotobynumber" ( BYVAL proto AS LONG ) AS QUAD ' struct protoent FAR *
DECLARE FUNCTION getprotobyname LIB "ws2_32.dll" ALIAS "getprotobyname" ( BYREF name AS ASCIIZ ) AS QUAD ' struct protoent FAR *
DECLARE FUNCTION WSAStartup LIB "ws2_32.dll" ALIAS "WSAStartup" ( BYVAL wVersionRequired AS WORD , BYREF lpWSAData AS WSADATA ) AS LONG ' int
DECLARE FUNCTION WSACleanup LIB "ws2_32.dll" ALIAS "WSACleanup" ( ) AS LONG ' int
DECLARE SUB WSASetLastError LIB "ws2_32.dll" ALIAS "WSASetLastError" ( BYVAL iError AS LONG ) ' void
DECLARE FUNCTION WSAGetLastError LIB "ws2_32.dll" ALIAS "WSAGetLastError" ( ) AS LONG ' int
DECLARE FUNCTION WSAIsBlocking LIB "ws2_32.dll" ALIAS "WSAIsBlocking" ( ) AS LONG
DECLARE FUNCTION WSAUnhookBlockingHook LIB "ws2_32.dll" ALIAS "WSAUnhookBlockingHook" ( ) AS LONG ' int
DECLARE FUNCTION WSASetBlockingHook LIB "ws2_32.dll" ALIAS "WSASetBlockingHook" ( BYVAL lpBlockFunc AS QUAD ) AS QUAD ' FARPROC
DECLARE FUNCTION WSACancelBlockingCall LIB "ws2_32.dll" ALIAS "WSACancelBlockingCall" ( ) AS LONG ' int
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAAsyncGetServByName LIB "ws2_32.dll" ALIAS "WSAAsyncGetServByName" ( BYVAL hWnd AS QUAD,
 BYVAL wMsg AS QUAD, serv_name AS ASCIIZ, proto AS ASCIIZ, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG ) AS QUAD
#ELSE
DECLARE FUNCTION WSAAsyncGetServByName LIB "ws2_32.dll" ALIAS "WSAAsyncGetServByName" ( BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYREF name AS ASCIIZ , BYREF proto AS ASCIIZ , BYREF buf AS ASCIIZ , BYVAL buflen AS LONG ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAAsyncGetServByPort LIB "ws2_32.dll" ALIAS "WSAAsyncGetServByPort" ( BYVAL hWnd AS QUAD,
 BYVAL wMsg AS QUAD, BYVAL lPort AS LONG, proto AS ASCIIZ, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG ) AS QUAD
#ELSE
DECLARE FUNCTION WSAAsyncGetServByPort LIB "ws2_32.dll" ALIAS "WSAAsyncGetServByPort" ( BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYVAL port AS LONG , BYREF proto AS ASCIIZ , BYREF buf AS ASCIIZ , BYVAL buflen AS LONG ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAAsyncGetProtoByName LIB "ws2_32.dll" ALIAS "WSAAsyncGetProtoByName" ( BYVAL hWnd AS QUAD,
 BYVAL wMsg AS QUAD, proto_name AS ASCIIZ, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG ) AS QUAD
#ELSE
DECLARE FUNCTION WSAAsyncGetProtoByName LIB "ws2_32.dll" ALIAS "WSAAsyncGetProtoByName" ( BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYREF name AS ASCIIZ , BYREF buf AS ASCIIZ , BYVAL buflen AS LONG ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAAsyncGetProtoByNumber LIB "ws2_32.dll" ALIAS "WSAAsyncGetProtoByNumber" ( BYVAL hWnd AS QUAD,
 BYVAL wMsg AS QUAD, BYVAL number AS LONG, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG ) AS QUAD
#ELSE
DECLARE FUNCTION WSAAsyncGetProtoByNumber LIB "ws2_32.dll" ALIAS "WSAAsyncGetProtoByNumber" ( BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYVAL name AS LONG , BYREF buf AS ASCIIZ , BYVAL buflen AS LONG ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAAsyncGetHostByName LIB "ws2_32.dll" ALIAS "WSAAsyncGetHostByName" ( BYVAL hWnd AS QUAD, BYVAL wMsg AS QUAD, host_name AS ASCIIZ, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG ) AS QUAD
#ELSE
DECLARE FUNCTION WSAAsyncGetHostByName LIB "ws2_32.dll" ALIAS "WSAAsyncGetHostByName" ( BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYREF name AS ASCIIZ , BYREF buf AS ASCIIZ , BYVAL buflen AS LONG ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAAsyncGetHostByAddr LIB "ws2_32.dll" ALIAS "WSAAsyncGetHostByAddr" ( BYVAL hWnd AS QUAD,
 BYVAL wMsg AS QUAD, BYVAL address AS BYTE PTR, BYVAL addr_len AS LONG, BYVAL addr_type AS LONG, BYVAL buf AS BYTE PTR, BYVAL buflen AS LONG ) AS QUAD
#ELSE
DECLARE FUNCTION WSAAsyncGetHostByAddr LIB "ws2_32.dll" ALIAS "WSAAsyncGetHostByAddr" ( BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYREF addr AS ASCIIZ , BYVAL len AS LONG , BYVAL type AS LONG , BYREF buf AS ASCIIZ , BYVAL buflen AS LONG ) AS QUAD
#ENDIF
DECLARE FUNCTION WSACancelAsyncRequest LIB "ws2_32.dll" ALIAS "WSACancelAsyncRequest" ( BYVAL hAsyncTaskHandle AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSAAsyncSelect LIB "ws2_32.dll" ALIAS "WSAAsyncSelect" ( BYVAL s AS QUAD , BYVAL hWnd AS QUAD , BYVAL wMsg AS QUAD , BYVAL lEvent AS LONG ) AS LONG ' int
'/* WinSock 2 API new function prototypes */
DECLARE FUNCTION WSAAccept LIB "ws2_32.dll" ALIAS "WSAAccept" ( BYVAL s AS QUAD , BYREF addr AS SOCKADDR , BYREF addrlen AS LONG , BYVAL lpfnCondition AS QUAD , BYVAL dwCallbackData AS QUAD ) AS QUAD ' SOCKET
DECLARE FUNCTION WSACloseEvent LIB "ws2_32.dll" ALIAS "WSACloseEvent" ( BYVAL hEvent AS QUAD ) AS LONG
DECLARE FUNCTION WSAConnect LIB "ws2_32.dll" ALIAS "WSAConnect" ( BYVAL s AS QUAD
 , BYREF name AS SOCKADDR
 , BYVAL namelen AS LONG
 , BYREF lpCallerData AS WSABUF
 , BYREF lpCalleeData AS WSABUF
 , BYREF lpSQOS AS QOS
 , BYREF lpGQOS AS QOS
 ) AS LONG ' int
DECLARE FUNCTION WSAConnectByNameW LIB "ws2_32.dll" ALIAS "WSAConnectByNameW" ( BYVAL s AS QUAD , BYREF nodename AS WSTRINGZ , BYREF servicename AS WSTRINGZ , BYREF LocalAddressLength AS QUAD , BYREF LocalAddress AS SOCKADDR , BYREF RemoteAddressLength AS QUAD , BYREF RemoteAddress AS SOCKADDR , BYREF timeout AS TIMEVAL , BYREF Reserved AS WSAOVERLAPPED ) AS LONG
DECLARE FUNCTION WSAConnectByNameA LIB "ws2_32.dll" ALIAS "WSAConnectByNameA" ( BYVAL s AS QUAD
 , BYREF nodename AS ASCIIZ
 , BYREF servicename AS ASCIIZ
 , BYREF LocalAddressLength AS DWORD
 , BYREF LocalAddress AS SOCKADDR
 , BYREF RemoteAddressLength AS DWORD
 , BYREF RemoteAddress AS SOCKADDR
 , BYREF timeout AS TIMEVAL
 , BYREF Reserved AS WSAOVERLAPPED
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WSAConnectByName = WSAConnectByNameW
#ELSE
 MACRO WSAConnectByName = WSAConnectByNameA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAConnectByList LIB "ws2_32.dll" ALIAS "WSAConnectByList" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL SocketAddress AS SOCKET_ADDRESS_LIST PTR, LocalAddressLength AS DWORD, LocalAddress AS SOCKADDR, RemoteAddressLength AS DWORD, RemoteAddress AS SOCKADDR, TIMEOUT AS timeval, Reserved AS WSAOVERLAPPED ) AS LONG
#ELSE
DECLARE FUNCTION WSAConnectByList LIB "ws2_32.dll" ALIAS "WSAConnectByList" ( BYVAL s AS QUAD , BYREF SocketAddress AS SOCKET_ADDRESS , BYREF LocalAddressLength AS QUAD , BYREF LocalAddress AS SOCKADDR , BYREF RemoteAddressLength AS QUAD , BYREF RemoteAddress AS SOCKADDR , BYREF timeout AS TIMEVAL , BYREF Reserved AS WSAOVERLAPPED ) AS LONG
#ENDIF
DECLARE FUNCTION WSACreateEvent LIB "ws2_32.dll" ALIAS "WSACreateEvent" ( ) AS QUAD ' WSAEVENT
DECLARE FUNCTION WSADuplicateSocketA LIB "ws2_32.dll" ALIAS "WSADuplicateSocketA" ( BYVAL s AS QUAD , BYVAL dwProcessId AS QUAD , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOA ) AS LONG ' int
DECLARE FUNCTION WSADuplicateSocketW LIB "ws2_32.dll" ALIAS "WSADuplicateSocketW" ( BYVAL s AS QUAD , BYVAL dwProcessId AS QUAD , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSADuplicateSocket = WSADuplicateSocketW
#ELSE
 MACRO WSADuplicateSocket = WSADuplicateSocketA
#ENDIF
DECLARE FUNCTION WSAEnumNetworkEvents LIB "ws2_32.dll" ALIAS "WSAEnumNetworkEvents" ( BYVAL s AS QUAD , BYVAL hEventObject AS QUAD , BYREF lpNetworkEvents AS WSANETWORKEVENTS ) AS LONG ' int
DECLARE FUNCTION WSAEnumProtocolsA LIB "ws2_32.dll" ALIAS "WSAEnumProtocolsA" ( BYREF lpiProtocols AS LONG , BYREF lpProtocolBuffer AS WSAPROTOCOL_INFOA , BYREF lpdwBufferLength AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSAEnumProtocolsW LIB "ws2_32.dll" ALIAS "WSAEnumProtocolsW" ( BYREF lpiProtocols AS LONG , BYREF lpProtocolBuffer AS WSAPROTOCOL_INFOW , BYREF lpdwBufferLength AS QUAD ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAEnumProtocols = WSAEnumProtocolsW
#ELSE
 MACRO WSAEnumProtocols = WSAEnumProtocolsA
#ENDIF
DECLARE FUNCTION WSAEventSelect LIB "ws2_32.dll" ALIAS "WSAEventSelect" ( BYVAL s AS QUAD , BYVAL hEventObject AS QUAD , BYVAL lNetworkEvents AS LONG ) AS LONG ' int
DECLARE FUNCTION WSAGetOverlappedResult LIB "ws2_32.dll" ALIAS "WSAGetOverlappedResult" ( BYVAL s AS QUAD , BYREF lpOverlapped AS WSAOVERLAPPED , BYREF lpcbTransfer AS QUAD , BYVAL fWait AS LONG , BYREF lpdwFlags AS QUAD ) AS LONG
DECLARE FUNCTION WSAGetQOSByName LIB "ws2_32.dll" ALIAS "WSAGetQOSByName" ( BYVAL s AS QUAD
 , BYREF lpQOSName AS WSABUF
 , BYREF lpQOS AS QOS
 ) AS LONG
DECLARE FUNCTION WSAHtonl LIB "ws2_32.dll" ALIAS "WSAHtonl" ( BYVAL s AS DWORD
 , BYVAL hostlong AS DWORD
 , BYREF lpnetlong AS DWORD
 ) AS LONG ' int
DECLARE FUNCTION WSAHtons LIB "ws2_32.dll" ALIAS "WSAHtons" ( BYVAL s AS QUAD , BYVAL hostshort AS WORD , BYREF lpnetshort AS WORD ) AS LONG ' int
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAIoctl LIB "ws2_32.dll" ALIAS "WSAIoctl" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL dwIoControlCode AS DWORD, lpvInBuffer AS ANY,
 BYVAL cbInBuffer AS DWORD, lpvOutBuffer AS ANY,
 BYVAL cbOutBuffer AS DWORD, lpcbBytesReturned AS DWORD, lpOverlapped AS WSAOVERLAPPED, BYVAL lpCompletionRoutine AS DWORD ' LPWSAOVERLAPPED_COMPLETION_ROUTINE
 ) AS LONG
#ELSE
DECLARE FUNCTION WSAIoctl LIB "ws2_32.dll" ALIAS "WSAIoctl" ( BYVAL s AS QUAD , BYVAL dwIoControlCode AS QUAD , BYVAL lpvInBuffer AS QUAD , BYVAL cbInBuffer AS QUAD , BYVAL lpvOutBuffer AS QUAD , BYVAL cbOutBuffer AS QUAD , BYREF lpcbBytesReturned AS QUAD , BYREF lpOverlapped AS WSAOVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG ' int
#ENDIF
DECLARE FUNCTION WSAJoinLeaf LIB "ws2_32.dll" ALIAS "WSAJoinLeaf" ( BYVAL s AS QUAD , BYREF name AS SOCKADDR , BYVAL namelen AS LONG , BYREF lpCallerData AS WSABUF , BYREF lpCalleeData AS WSABUF , BYREF lpSQOS AS QOS , BYREF lpGQOS AS QOS , BYVAL dwFlags AS QUAD ) AS QUAD ' SOCKET
DECLARE FUNCTION WSANtohl LIB "ws2_32.dll" ALIAS "WSANtohl" ( BYVAL s AS QUAD , BYVAL netlong AS QUAD , BYREF lphostlong AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSANtohs LIB "ws2_32.dll" ALIAS "WSANtohs" ( BYVAL s AS QUAD , BYVAL netshort AS WORD , BYREF lphostshort AS WORD ) AS LONG ' int
DECLARE FUNCTION WSARecv LIB "ws2_32.dll" ALIAS "WSARecv" ( BYVAL s AS QUAD , BYREF lpBuffers AS WSABUF , BYVAL dwBufferCount AS QUAD , BYREF lpNumberOfBytesRecvd AS QUAD , BYREF lpFlags AS QUAD , BYREF lpOverlapped AS WSAOVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSARecvDisconnect LIB "ws2_32.dll" ALIAS "WSARecvDisconnect" ( BYVAL s AS QUAD , BYREF lpInboundDisconnectData AS WSABUF ) AS LONG ' int
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSARecvFrom LIB "ws2_32.dll" ALIAS "WSARecvFrom" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL lpBuffers AS WSABUF PTR, BYVAL dwBufferCount AS DWORD, lpNumberOfBytesRecvd AS DWORD, lpFlags AS DWORD, lpFrom AS SOCKADDR, lpFromlen AS LONG, lpOverlapped AS WSAOVERLAPPED, BYVAL lpCompletionRoutine AS DWORD ' LPWSAOVERLAPPED_COMPLETION_ROUTINE
 ) AS LONG
#ELSE
DECLARE FUNCTION WSARecvFrom LIB "ws2_32.dll" ALIAS "WSARecvFrom" ( BYVAL s AS QUAD , BYREF lpBuffers AS WSABUF , BYVAL dwBufferCount AS QUAD , BYREF lpNumberOfBytesRecvd AS QUAD , BYREF lpFlags AS QUAD , BYREF lpFrom AS SOCKADDR , BYREF lpFromlen AS LONG , BYREF lpOverlapped AS WSAOVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG ' int
#ENDIF
DECLARE FUNCTION WSAResetEvent LIB "ws2_32.dll" ALIAS "WSAResetEvent" ( BYVAL hEvent AS QUAD ) AS LONG
DECLARE FUNCTION WSASend LIB "ws2_32.dll" ALIAS "WSASend" ( BYVAL s AS QUAD
 , BYREF lpBuffers AS WSABUF
 , BYVAL dwBufferCount AS DWORD
 , BYREF lpNumberOfBytesSent AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF lpOverlapped AS WSAOVERLAPPED
 , BYVAL lpCompletionRoutine AS DWORD
 ) AS LONG ' int
DECLARE FUNCTION WSASendMsg LIB "ws2_32.dll" ALIAS "WSASendMsg" ( BYVAL s AS QUAD , BYREF lpMsg AS WSAMSG , BYVAL dwFlags AS QUAD , BYREF lpNumberOfBytesSent AS QUAD , BYREF lpOverlapped AS WSAOVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSASendDisconnect LIB "ws2_32.dll" ALIAS "WSASendDisconnect" ( BYVAL s AS QUAD , BYREF lpOutboundDisconnectData AS WSABUF ) AS LONG ' int
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSASendTo LIB "ws2_32.dll" ALIAS "WSASendTo" ( BYVAL s AS QUAD, ' SOCKET
 BYVAL lpBuffers AS WSABUF PTR, BYVAL dwBufferCount AS DWORD, lpNumberOfBytesSent AS DWORD, BYVAL dwFlags AS DWORD, lpTo AS SOCKADDR, BYVAL iTolen AS LONG, lpOverlapped AS WSAOVERLAPPED, BYVAL lpCompletionRoutine AS DWORD ' LPWSAOVERLAPPED_COMPLETION_ROUTINE
 ) AS LONG
#ELSE
DECLARE FUNCTION WSASendTo LIB "ws2_32.dll" ALIAS "WSASendTo" ( BYVAL s AS QUAD , BYREF lpBuffers AS WSABUF , BYVAL dwBufferCount AS QUAD , BYREF lpNumberOfBytesSent AS QUAD , BYVAL dwFlags AS QUAD , BYREF lpTo AS SOCKADDR , BYVAL iTolen AS LONG , BYREF lpOverlapped AS WSAOVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG ' int
#ENDIF
DECLARE FUNCTION WSASetEvent LIB "ws2_32.dll" ALIAS "WSASetEvent" ( BYVAL hEvent AS QUAD ) AS LONG
DECLARE FUNCTION WSASocketA LIB "ws2_32.dll" ALIAS "WSASocketA" ( BYVAL af AS LONG
 , BYVAL type AS LONG
 , BYVAL protocol AS LONG
 , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOA
 , BYVAL g AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD ' SOCKET
DECLARE FUNCTION WSASocketW LIB "ws2_32.dll" ALIAS "WSASocketW" ( BYVAL af AS LONG , BYVAL type AS LONG , BYVAL protocol AS LONG , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOW , BYVAL g AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' SOCKET
#IF %DEF(%UNICODE)
 MACRO WSASocket = WSASocketW
#ELSE
 MACRO WSASocket = WSASocketA
#ENDIF
DECLARE FUNCTION WSAWaitForMultipleEvents LIB "ws2_32.dll" ALIAS "WSAWaitForMultipleEvents" ( BYVAL cEvents AS QUAD , BYVAL lphEvents AS QUAD PTR , BYVAL fWaitAll AS LONG , BYVAL dwTimeout AS QUAD , BYVAL fAlertable AS LONG ) AS QUAD
DECLARE FUNCTION WSAAddressToStringA LIB "ws2_32.dll" ALIAS "WSAAddressToStringA" ( BYREF lpsaAddress AS SOCKADDR
 , BYVAL dwAddressLength AS DWORD
 , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOA
 , BYREF lpszAddressString AS ASCIIZ
 , BYREF lpdwAddressStringLength AS DWORD
 ) AS LONG ' int
DECLARE FUNCTION WSAAddressToStringW LIB "ws2_32.dll" ALIAS "WSAAddressToStringW" ( BYREF lpsaAddress AS SOCKADDR , BYVAL dwAddressLength AS QUAD , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOW , BYREF lpszAddressString AS WSTRINGZ , BYREF lpdwAddressStringLength AS QUAD ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAAddressToString = WSAAddressToStringW
#ELSE
 MACRO WSAAddressToString = WSAAddressToStringA
#ENDIF
DECLARE FUNCTION WSAStringToAddressA LIB "ws2_32.dll" ALIAS "WSAStringToAddressA" ( BYREF AddressString AS ASCIIZ , BYVAL AddressFamily AS LONG , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOA , BYREF lpAddress AS SOCKADDR , BYREF lpAddressLength AS LONG ) AS LONG ' int
DECLARE FUNCTION WSAStringToAddressW LIB "ws2_32.dll" ALIAS "WSAStringToAddressW" ( BYREF AddressString AS WSTRINGZ , BYVAL AddressFamily AS LONG , BYREF lpProtocolInfo AS WSAPROTOCOL_INFOW , BYREF lpAddress AS SOCKADDR , BYREF lpAddressLength AS LONG ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAStringToAddress = WSAStringToAddressW
#ELSE
 MACRO WSAStringToAddress = WSAStringToAddressA
#ENDIF
'/* Registration and Name Resolution API functions */
DECLARE FUNCTION WSALookupServiceBeginA LIB "ws2_32.dll" ALIAS "WSALookupServiceBeginA" ( BYREF lpqsRestrictions AS WSAQUERYSETA , BYVAL dwControlFlags AS QUAD , BYREF lphLookup AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSALookupServiceBeginW LIB "ws2_32.dll" ALIAS "WSALookupServiceBeginW" ( BYREF lpqsRestrictions AS WSAQUERYSETW , BYVAL dwControlFlags AS QUAD , BYREF lphLookup AS QUAD ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSALookupServiceBegin = WSALookupServiceBeginW
#ELSE
 MACRO WSALookupServiceBegin = WSALookupServiceBeginA
#ENDIF
DECLARE FUNCTION WSALookupServiceNextA LIB "ws2_32.dll" ALIAS "WSALookupServiceNextA" ( BYVAL hLookup AS QUAD , BYVAL dwControlFlags AS QUAD , BYREF lpdwBufferLength AS QUAD , BYREF lpqsResults AS WSAQUERYSETA ) AS LONG ' int
DECLARE FUNCTION WSALookupServiceNextW LIB "ws2_32.dll" ALIAS "WSALookupServiceNextW" ( BYVAL hLookup AS QUAD , BYVAL dwControlFlags AS QUAD , BYREF lpdwBufferLength AS QUAD , BYREF lpqsResults AS WSAQUERYSETW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSALookupServiceNext = WSALookupServiceNextW
#ELSE
 MACRO WSALookupServiceNext = WSALookupServiceNextA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSANSPIoctl LIB "ws2_32.dll" ALIAS "WSANSPIoctl" ( BYVAL hLookup AS QUAD,
 BYVAL dwControlCode AS QUAD, lpvInBuffer AS ANY,
 BYVAL cbInBuffer AS QUAD, lpvOutBuffer AS ANY,
 BYVAL cbOutBuffer AS QUAD, lpcbBytesReturned AS QUAD, lpCompletion AS WSACOMPLETION ) AS LONG
#ELSE
DECLARE FUNCTION WSANSPIoctl LIB "ws2_32.dll" ALIAS "WSANSPIoctl" ( BYVAL hLookup AS QUAD , BYVAL dwControlCode AS QUAD , BYVAL lpvInBuffer AS QUAD , BYVAL cbInBuffer AS QUAD , BYVAL lpvOutBuffer AS QUAD , BYVAL cbOutBuffer AS QUAD , BYREF lpcbBytesReturned AS QUAD , BYREF lpCompletion AS WSACOMPLETION ) AS LONG ' int
#ENDIF
DECLARE FUNCTION WSALookupServiceEnd LIB "ws2_32.dll" ALIAS "WSALookupServiceEnd" ( BYVAL hLookup AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSAInstallServiceClassA LIB "ws2_32.dll" ALIAS "WSAInstallServiceClassA" ( BYREF lpServiceClassInfo AS WSASERVICECLASSINFOA ) AS LONG ' int
DECLARE FUNCTION WSAInstallServiceClassW LIB "ws2_32.dll" ALIAS "WSAInstallServiceClassW" ( BYREF lpServiceClassInfo AS WSASERVICECLASSINFOW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAInstallServiceClass = WSAInstallServiceClassW
#ELSE
 MACRO WSAInstallServiceClass = WSAInstallServiceClassA
#ENDIF
'#if INCL_WINSOCK_API_PROTOTYPES
DECLARE FUNCTION WSARemoveServiceClass LIB "ws2_32.dll" ALIAS "WSARemoveServiceClass" ( BYREF lpServiceClassId AS GUID ) AS LONG ' int
DECLARE FUNCTION WSAGetServiceClassInfoA LIB "ws2_32.dll" ALIAS "WSAGetServiceClassInfoA" ( BYREF lpProviderId AS GUID , BYREF lpServiceClassId AS GUID , BYREF lpdwBufSize AS QUAD , BYREF lpServiceClassInfo AS WSASERVICECLASSINFOA ) AS LONG ' int
DECLARE FUNCTION WSAGetServiceClassInfoW LIB "ws2_32.dll" ALIAS "WSAGetServiceClassInfoW" ( BYREF lpProviderId AS GUID , BYREF lpServiceClassId AS GUID , BYREF lpdwBufSize AS QUAD , BYREF lpServiceClassInfo AS WSASERVICECLASSINFOW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAGetServiceClassInfo = WSAGetServiceClassInfoW
#ELSE
 MACRO WSAGetServiceClassInfo = WSAGetServiceClassInfoA
#ENDIF
DECLARE FUNCTION WSAEnumNameSpaceProvidersA LIB "ws2_32.dll" ALIAS "WSAEnumNameSpaceProvidersA" ( BYREF lpdwBufferLength AS QUAD , BYREF lpnspBuffer AS WSANAMESPACE_INFOA ) AS LONG ' int
DECLARE FUNCTION WSAEnumNameSpaceProvidersW LIB "ws2_32.dll" ALIAS "WSAEnumNameSpaceProvidersW" ( BYREF lpdwBufferLength AS QUAD , BYREF lpnspBuffer AS WSANAMESPACE_INFOW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAEnumNameSpaceProviders = WSAEnumNameSpaceProvidersW
#ELSE
 MACRO WSAEnumNameSpaceProviders = WSAEnumNameSpaceProvidersA
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
DECLARE FUNCTION WSAEnumNameSpaceProvidersExA LIB "ws2_32.dll" ALIAS "WSAEnumNameSpaceProvidersExA" ( BYREF lpdwBufferLength AS QUAD , BYREF lpnspBuffer AS WSANAMESPACE_INFOEXA ) AS LONG ' int
DECLARE FUNCTION WSAEnumNameSpaceProvidersExW LIB "ws2_32.dll" ALIAS "WSAEnumNameSpaceProvidersExW" ( BYREF lpdwBufferLength AS QUAD , BYREF lpnspBuffer AS WSANAMESPACE_INFOEXW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAEnumNameSpaceProvidersEx = WSAEnumNameSpaceProvidersExW
#ELSE
 MACRO WSAEnumNameSpaceProvidersEx = WSAEnumNameSpaceProvidersExA
#ENDIF
'#endif //(_WIN32_WINNT >= 0x600)
DECLARE FUNCTION WSAGetServiceClassNameByClassIdA LIB "ws2_32.dll" ALIAS "WSAGetServiceClassNameByClassIdA" ( BYREF lpServiceClassId AS GUID , BYREF lpszServiceClassName AS ASCIIZ , BYREF lpdwBufferLength AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSAGetServiceClassNameByClassIdW LIB "ws2_32.dll" ALIAS "WSAGetServiceClassNameByClassIdW" ( BYREF lpServiceClassId AS GUID , BYREF lpszServiceClassName AS WSTRINGZ , BYREF lpdwBufferLength AS QUAD ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSAGetServiceClassNameByClassId = WSAGetServiceClassNameByClassIdW
#ELSE
 MACRO WSAGetServiceClassNameByClassId = WSAGetServiceClassNameByClassIdA
#ENDIF
DECLARE FUNCTION WSASetServiceA LIB "ws2_32.dll" ALIAS "WSASetServiceA" ( BYREF lpqsRegInfo AS WSAQUERYSETA , BYVAL essoperation AS LONG , BYVAL dwControlFlags AS QUAD ) AS LONG ' int
DECLARE FUNCTION WSASetServiceW LIB "ws2_32.dll" ALIAS "WSASetServiceW" ( BYREF lpqsRegInfo AS WSAQUERYSETW , BYVAL essoperation AS LONG , BYVAL dwControlFlags AS QUAD ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO WSASetService = WSASetServiceW
#ELSE
 MACRO WSASetService = WSASetServiceA
#ENDIF
DECLARE FUNCTION WSAProviderConfigChange LIB "ws2_32.dll" ALIAS "WSAProviderConfigChange" ( BYREF lpNotificationHandle AS QUAD , BYREF lpOverlapped AS WSAOVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG ' int
'#if(_WIN32_WINNT >= 0x0600)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WSAPoll LIB "ws2_32.dll" ALIAS "WSAPoll" ( BYVAL fdArray AS WSAPOLLFD PTR, BYVAL fds AS QUAD, BYVAL TIMEOUT AS LONG ) AS LONG
#ELSE
DECLARE FUNCTION WSAPoll LIB "ws2_32.dll" ALIAS "WSAPoll" ( BYREF fdArray AS WSAPOLLFD , BYVAL fds AS QUAD , BYVAL timeout AS LONG ) AS LONG ' int
#ENDIF
'#endif // (_WIN32_WINNT >= 0x0600)
'#ENDIF ' #IF (%INCL_WINSOCK_API_PROTOTYPES) -----------------------------------
'/* Microsoft Windows Extended data types */
'typedef struct sockaddr_in SOCKADDR_IN;
'typedef struct sockaddr_in *PSOCKADDR_IN;
'typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
'typedef struct linger LINGER;
'typedef struct linger *PLINGER;
'typedef struct linger FAR *LPLINGER;
'typedef struct in_addr IN_ADDR;
'typedef struct in_addr *PIN_ADDR;
'typedef struct in_addr FAR *LPIN_ADDR;
'typedef struct fd_set FD_SET;
'typedef struct fd_set *PFD_SET;
'typedef struct fd_set FAR *LPFD_SET;
'typedef struct hostent HOSTENT;
'typedef struct hostent *PHOSTENT;
'typedef struct hostent FAR *LPHOSTENT;
'typedef struct servent SERVENT;
'typedef struct servent *PSERVENT;
'typedef struct servent FAR *LPSERVENT;
'typedef struct protoent PROTOENT;
'typedef struct protoent *PPROTOENT;
'typedef struct protoent FAR *LPPROTOENT;
'typedef struct timeval TIMEVAL;
'typedef struct timeval *PTIMEVAL;
'typedef struct timeval FAR *LPTIMEVAL;
'/*
' * Windows message parameter composition and decomposition
' * macros.
' *
' * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
' * when constructing the response to a WSAAsyncGetXByY() routine.
' */
'#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
FUNCTION WSAMAKEASYNCREPLY (BYVAL wbuflen AS WORD, BYVAL werror AS WORD) AS LONG
 FUNCTION = MAK(LONG, wbuflen, werror)
END FUNCTION
'/*
' * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
' * when constructing the response to WSAAsyncSelect().
' */
'#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
FUNCTION WSAMAKESELECTREPLY (BYVAL wevent AS WORD, BYVAL werror AS WORD) AS LONG
 FUNCTION = MAK(LONG, wevent, werror)
END FUNCTION
'/*
' * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
' * to extract the buffer length from the lParam in the response
' * to a WSAAsyncGetXByY().
' */
'#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
FUNCTION WSAGETASYNCBUFLEN (BYVAL lParam AS LONG) AS WORD
 FUNCTION = LO(WORD, lParam)
END FUNCTION
'/*
' * WSAGETASYNCERROR is intended for use by the Windows Sockets application
' * to extract the error code from the lParam in the response
' * to a WSAGetXByY().
' */
'#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
FUNCTION WSAGETASYNCERROR (BYVAL lParam AS LONG) AS WORD
 FUNCTION = HI(WORD, lParam)
END FUNCTION
'/*
' * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
' * to extract the event code from the lParam in the response
' * to a WSAAsyncSelect().
' */
'#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
FUNCTION WSAGETSELECTEVENT (BYVAL lParam AS LONG) AS WORD
 FUNCTION = LO(WORD, lParam)
END FUNCTION
'/*
' * WSAGETSELECTERROR is intended for use by the Windows Sockets application
' * to extract the error code from the lParam in the response
' * to a WSAAsyncSelect().
' */
'#define WSAGETSELECTERROR(lParam) HIWORD(lParam)
FUNCTION WSAGETSELECTERROR (BYVAL lParam AS LONG) AS WORD
 FUNCTION = HI(WORD, lParam)
END FUNCTION
' Return a pointer to all of the host IP addresses
FUNCTION GetHostAddr () AS DWORD
 LOCAL phostent AS hostent PTR
 LOCAL hostname AS ASCIIZ * 256
 IF gethostname(hostname, SIZEOF(hostname)) = 0 THEN
 IF LEN(hostname) THEN
 phostent = gethostbyname(hostname)
 IF phostent THEN
 FUNCTION = @phostent.h_addr_list
 END IF
 END IF
 END IF
END FUNCTION
FUNCTION h_errno () AS LONG
 FUNCTION = WSAGetLastError
END FUNCTION
'#if(_WIN32_WINNT >= 0x0501)
'#ifdef IPV6STRICT
'#include <wsipv6ok.h>
'#endif // IPV6STRICT
'#endif //(_WIN32_WINNT >= 0x0501)
#ENDIF ' #IF NOT %DEF(%WINSOCK2API)
#ENDIF
