Ignore:
Timestamp:
Dec 30, 2006, 11:20:03 PM (18 years ago)
Author:
イグトランス (egtra)
Message:

api_winerror.sbpとapi_winsock2.sbpとの間での定義の重複を除去など。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/api_winsock2.sbp

    r24 r42  
    1 ' api_winsock2.sbp
    2 'Windows Sockets Ver2.0
    3 
    4 
    5 #ifndef _INC_WINSOCK2
    6 #define _INC_WINSOCK2
     1#ifndef _WINSOCK2API_
     2#define _WINSOCK2API_
     3#define _WINSOCKAPI_
     4/*
     5#ifndef INCL_WINSOCK_API_PROTOTYPES
     6#define INCL_WINSOCK_API_PROTOTYPES 1
     7#endif
     8
     9#ifndef INCL_WINSOCK_API_TYPEDEFS
     10#define INCL_WINSOCK_API_TYPEDEFS 0
     11#endif
     12*/
     13
     14Const WINSOCK_VERSION = MAKEWORD(2, 2)
    715
    816TypeDef SOCKET = ULONG_PTR
    917
    10 Const SOCKET_ERROR = -1
    11 Const INVALID_SOCKET = -1
    12 
    13 
    14 'Port/socket numbers - network standard functions
    15 Const IPPORT_ECHO =           7
    16 Const IPPORT_DISCARD =        9
    17 Const IPPORT_SYSTAT =         11
    18 Const IPPORT_DAYTIME =        13
    19 Const IPPORT_NETSTAT =        15
    20 Const IPPORT_FTP =            21
    21 Const IPPORT_TELNET =         23
    22 Const IPPORT_SMTP =           25
    23 Const IPPORT_TIMESERVER =     37
    24 Const IPPORT_NAMESERVER =     42
    25 Const IPPORT_WHOIS =          43
    26 Const IPPORT_MTP =            57
    27 
    28 
    29 'Address families
    30 Const AF_UNSPEC =     0
    31 Const AF_UNIX =       1
    32 Const AF_INET =       2
    33 Const AF_IMPLINK =    3
    34 Const AF_PUP =        4
    35 Const AF_CHAOS =      5
    36 Const AF_NS =         6
    37 Const AF_IPX =        AF_NS
    38 Const AF_ISO =        7
    39 Const AF_OSI =        AF_ISO
    40 Const AF_ECMA =       8
    41 Const AF_DATAKIT =    9
    42 Const AF_CCITT =      10
    43 Const AF_SNA =        11
    44 Const AF_DECnet =     12
    45 Const AF_DLI =        13
    46 Const AF_LAT =        14
    47 Const AF_HYLINK =     15
    48 Const AF_APPLETALK =  16
    49 Const AF_NETBIOS =    17
    50 Const AF_VOICEVIEW =  18
    51 Const AF_FIREFOX =    19
    52 Const AF_UNKNOWN1 =   20
    53 Const AF_BAN =        21
    54 Const AF_ATM =        22
    55 Const AF_INET6 =      23
    56 Const AF_CLUSTER =    24
    57 Const AF_12844 =      25
    58 Const AF_MAX =        26
    59 
    60 
    61 'Protocol families
    62 Const PF_UNSPEC =     AF_UNSPEC
    63 Const PF_UNIX =       AF_UNIX
    64 Const PF_INET =       AF_INET
    65 Const PF_IMPLINK =    AF_IMPLINK
    66 Const PF_PUP =        AF_PUP
    67 Const PF_CHAOS =      AF_CHAOS
    68 Const PF_NS =         AF_NS
    69 Const PF_IPX =        AF_IPX
    70 Const PF_ISO =        AF_ISO
    71 Const PF_OSI =        AF_OSI
    72 Const PF_ECMA =       AF_ECMA
    73 Const PF_DATAKIT =    AF_DATAKIT
    74 Const PF_CCITT =      AF_CCITT
    75 Const PF_SNA =        AF_SNA
    76 Const PF_DECnet =     AF_DECnet
    77 Const PF_DLI =        AF_DLI
    78 Const PF_LAT =        AF_LAT
    79 Const PF_HYLINK =     AF_HYLINK
    80 Const PF_APPLETALK =  AF_APPLETALK
    81 Const PF_VOICEVIEW =  AF_VOICEVIEW
    82 Const PF_FIREFOX =    AF_FIREFOX
    83 Const PF_UNKNOWN1 =   AF_UNKNOWN1
    84 Const PF_BAN =        AF_BAN
    85 Const PF_ATM =        AF_ATM
    86 Const PF_INET6 =      AF_INET6
    87 Const PF_MAX =        AF_MAX
    88 
    89 
    90 Const MSG_OOB =       1       'process out-of-band data
    91 Const MSG_PEEK =      2       'peek at incoming message
    92 Const MSG_DONTROUTE = 4       'send without using routing tables
    93 
    94 
    95 'Error code
    96 Const WSABASEERR =            10000
    97 Const WSAEINTR =              WSABASEERR+4
    98 Const WSAEBADF =              WSABASEERR+9
    99 Const WSAEACCES =             WSABASEERR+13
    100 Const WSAEFAULT =             WSABASEERR+14
    101 Const WSAEINVAL =             WSABASEERR+22
    102 Const WSAEMFILE =             WSABASEERR+24
    103 Const WSAEWOULDBLOCK =        WSABASEERR+35
    104 Const WSAEINPROGRESS =        WSABASEERR+36
    105 Const WSAEALREADY =           WSABASEERR+37
    106 Const WSAENOTSOCK =           WSABASEERR+38
    107 Const WSAEDESTADDRREQ =       WSABASEERR+39
    108 Const WSAEMSGSIZE =           WSABASEERR+40
    109 Const WSAEPROTOTYPE =         WSABASEERR+41
    110 Const WSAENOPROTOOPT =        WSABASEERR+42
    111 Const WSAEPROTONOSUPPORT =    WSABASEERR+43
    112 Const WSAESOCKTNOSUPPORT =    WSABASEERR+44
    113 Const WSAEOPNOTSUPP =         WSABASEERR+45
    114 Const WSAEPFNOSUPPORT =       WSABASEERR+46
    115 Const WSAEAFNOSUPPORT =       WSABASEERR+47
    116 Const WSAEADDRINUSE =         WSABASEERR+48
    117 Const WSAEADDRNOTAVAIL =      WSABASEERR+49
    118 Const WSAENETDOWN =           WSABASEERR+50
    119 Const WSAENETUNREACH =        WSABASEERR+51
    120 Const WSAENETRESET =          WSABASEERR+52
    121 Const WSAECONNABORTED =       WSABASEERR+53
    122 Const WSAECONNRESET =         WSABASEERR+54
    123 Const WSAENOBUFS =            WSABASEERR+55
    124 Const WSAEISCONN =            WSABASEERR+56
    125 Const WSAENOTCONN =           WSABASEERR+57
    126 Const WSAESHUTDOWN =          WSABASEERR+58
    127 Const WSAETOOMANYREFS =       WSABASEERR+59
    128 Const WSAETIMEDOUT =          WSABASEERR+60
    129 Const WSAECONNREFUSED =       WSABASEERR+61
    130 Const WSAELOOP =              WSABASEERR+62
    131 Const WSAENAMETOOLONG =       WSABASEERR+63
    132 Const WSAEHOSTDOWN =          WSABASEERR+64
    133 Const WSAEHOSTUNREACH =       WSABASEERR+65
    134 Const WSAENOTEMPTY =          WSABASEERR+66
    135 Const WSAEPROCLIM =           WSABASEERR+67
    136 Const WSAEUSERS =             WSABASEERR+68
    137 Const WSAEDQUOT =             WSABASEERR+69
    138 Const WSAESTALE =             WSABASEERR+70
    139 Const WSAEREMOTE =            WSABASEERR+71
    140 Const WSASYSNOTREADY =        WSABASEERR+91
    141 Const WSAVERNOTSUPPORTED =    WSABASEERR+92
    142 Const WSANOTINITIALISED =     WSABASEERR+93
    143 Const WSAEDISCON =            WSABASEERR+101
    144 Const WSAENOMORE =            WSABASEERR+102
    145 Const WSAECANCELLED =         WSABASEERR+103
    146 Const WSAEINVALIDPROCTABLE =  WSABASEERR+104
    147 Const WSAEINVALIDPROVIDER =   WSABASEERR+105
    148 Const WSAEPROVIDERFAILEDINIT =WSABASEERR+106
    149 Const WSASYSCALLFAILURE =     WSABASEERR+107
    150 Const WSASERVICE_NOT_FOUND =  WSABASEERR+108
    151 Const WSATYPE_NOT_FOUND =     WSABASEERR+109
    152 Const WSA_E_NO_MORE =         WSABASEERR+110
    153 Const WSA_E_CANCELLED =       WSABASEERR+111
    154 Const WSAEREFUSED =           WSABASEERR+112
    155 
    156 
    157 
    158 '---------------
    159 ' WinSock Types
    160 '---------------
    161 
    162 Type HOSTENT
    163     h_name As BytePtr
    164     h_aliases As DWordPtr
     18Const FD_SETSIZE = 64
     19
     20Type fd_set
     21    fd_count As DWord
     22    fd_array[ELM(FD_SETSIZE)] As SOCKET
     23End Type
     24
     25Declare Function __WSAFDIsSet Lib "ws2_32" (fd As SOCKET, ByRef set As fd_set) As Long
     26
     27Sub FD_CLR(fd As SOCKET, ByRef set As fd_set)
     28    Dim i As DWord
     29    With set
     30        For i = 0 To .fd_count
     31            If .fd_array[i] = fd Then
     32                While i < .fd_count - 1
     33                    .fd_array[i] = .fd_array[i + 1]
     34                WEnd
     35                .fd_count--
     36                Exit For
     37            End If
     38        Next
     39    End With
     40End Sub
     41
     42Sub FD_SET(fd As SOCKET, ByRef set As fd_set)
     43    Dim i As DWord
     44    With set
     45        For i = 0 To ELM(.fd_count)
     46            If .fd_array[i] = fd Then
     47                Exit Sub
     48            End If
     49        Next
     50        If i = .fd_count Then
     51            If .fd_count < FD_SET_SIZE Then
     52                .fd_array[i] = fd
     53                .fd_count++
     54            End If
     55        End If
     56    End With
     57End Sub
     58
     59Sub FD_ZERO(ByRef set As fd_set)
     60    set.fd_count = 0
     61End Sub
     62
     63Const FD_ISSET(fd, set) = __WSAFDIsSet(fd, set)
     64
     65Type timeval
     66    tv_sec As  Long
     67    tv_usec As  Long
     68End Type
     69
     70' Operations on timevals.
     71Function timerisset(ByRef tvp As timeval) As BOOL
     72    Return tvp.tv_sec Or tvp.tv_usec
     73End Function
     74
     75/*
     76#define timercmp(tvp, uvp, cmp) \
     77        ((tvp)->tv_sec cmp (uvp)->tv_sec || \
     78         (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
     79*/
     80
     81Sub timerclear(ByRef tvp As timeval)
     82    tvp.tv_sec = 0
     83    tvp.tv_usec = 0
     84End Sub
     85
     86' Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
     87Const IOCPARM_MASK = &h7f
     88Const IOC_VOID = &h20000000
     89Const IOC_OUT = &h40000000
     90Const IOC_IN = &h80000000
     91Const IOC_INOUT= (IOC_IN Or IOC_OUT)
     92
     93Const _IO(x ,y) = (IOC_VOID Or (x << 8) Or y)
     94
     95Const _IOR(x, y, size) = (IOC_OUT Or ((size And IOCPARM_MASK) << 16) Or ((x) << 8) Or (y))
     96
     97Const _IOW(x, y, size) = (IOC_IN Or ((size And IOCPARM_MASK) << 16) Or ((x) << 8) Or (y))
     98
     99Const FIONREAD = _IOR(&h66,127, SizeOf (DWord)) '&h66は'f'
     100Const FIONBIO = _IOW(&h66,126, SizeOf (DWord))
     101Const FIOASYNC = _IOW(&h66,125, SizeOf (DWord))
     102
     103' Socket I/O Controls
     104Const SIOCSHIWAT = _IOW(&h73, 0, SizeOf (DWord)) '&h73は's'
     105Const SIOCGHIWAT = _IOR(&h73, 1, SizeOf (DWord))
     106Const SIOCSLOWAT = _IOW(&h73, 2, SizeOf (DWord))
     107Const SIOCGLOWAT = _IOR(&h73, 3, SizeOf (DWord))
     108Const SIOCATMARK = _IOR(&h73, 7, SizeOf (DWord))
     109
     110
     111Class hostent
     112Public
     113    h_name As *Byte
     114    h_aliases As **Byte
    165115    h_addrtype As Integer
    166     h_length As Integer
    167     h_addr_list As DWordPtr
    168 End Type
    169 
    170 Type SERVENT
    171     s_name As BytePtr
    172     s_aliases As DWordPtr
     116    h_lengt As Integer
     117    h_addr_list As **Byte
     118
     119    Function h_addr() As *Byte
     120        Return h_addr_list[0]
     121    End Function
     122
     123    Sub h_addr(l As *Byte)
     124        h_addr_list[0] = i
     125    End Sub
     126End Class
     127
     128Type netent
     129    FAR * n_name As *Byte
     130    FAR * FAR * n_aliases As **Byte
     131    n_addrtyp As Integer
     132    n_net As DWord
     133End Type
     134
     135Type servent
     136    s_name As *Byte
     137    s_aliases As **Byte
     138#ifdef _WIN64
     139    s_proto As *Byte
    173140    s_port As Integer
    174     s_proto As BytePtr
    175 End Type
    176 
    177 Type SOCKADDR
    178     sa_family As Word
    179     sa_data[13] As Byte
    180 End Type
    181 Type SOCKADDR_IN
    182     sin_family As Word
     141#else
     142    s_port As Integer
     143    s_proto As *Byte
     144#endif
     145End Type
     146
     147Type protoent
     148    p_name As *Byte
     149    p_aliases As **Byte
     150    p_proto As Integer
     151End Type
     152
     153' Protocols
     154Const IPPROTO_IP = 0
     155Const IPPROTO_HOPOPTS = 0
     156Const IPPROTO_ICMP = 1
     157Const IPPROTO_IGMP = 2
     158Const IPPROTO_GGP = 3
     159Const IPPROTO_IPV4 = 4
     160Const IPPROTO_TCP = 6
     161Const IPPROTO_PUP = 12
     162Const IPPROTO_UDP = 17
     163Const IPPROTO_IDP = 22
     164Const IPPROTO_IPV6 = 41
     165Const IPPROTO_ROUTING = 43
     166Const IPPROTO_FRAGMENT = 44
     167Const IPPROTO_ESP = 50
     168Const IPPROTO_AH = 51
     169Const IPPROTO_ICMPV6 = 58
     170Const IPPROTO_NONE = 59
     171Const IPPROTO_DSTOPTS = 60
     172Const IPPROTO_ND = 77
     173Const IPPROTO_ICLFXBM = 78
     174
     175Const IPPROTO_RAW = 255
     176Const IPPROTO_MAX = 256
     177
     178' Port/socket numbers: network standard functions
     179Const IPPORT_ECHO = 7
     180Const IPPORT_DISCARD = 9
     181Const IPPORT_SYSTAT = 11
     182Const IPPORT_DAYTIME = 13
     183Const IPPORT_NETSTAT = 15
     184Const IPPORT_FTP = 21
     185Const IPPORT_TELNET = 23
     186Const IPPORT_SMTP = 25
     187Const IPPORT_TIMESERVER = 37
     188Const IPPORT_NAMESERVER = 42
     189Const IPPORT_WHOIS = 43
     190Const IPPORT_MTP = 57
     191
     192' Port/socket numbers: host specific functions
     193Const IPPORT_TFTP = 69
     194Const IPPORT_RJE = 77
     195Const IPPORT_FINGER = 79
     196Const IPPORT_TTYLINK = 87
     197Const IPPORT_SUPDUP = 95
     198
     199' UNIX TCP sockets
     200Const IPPORT_EXECSERVER = 512
     201Const IPPORT_LOGINSERVER = 513
     202Const IPPORT_CMDSERVER = 514
     203Const IPPORT_EFSSERVER = 520
     204
     205' UNIX UDP sockets
     206Const IPPORT_BIFFUDP = 512
     207Const IPPORT_WHOSERVER = 513
     208Const IPPORT_ROUTESERVER = 520
     209' 520+1 also used
     210
     211' Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root).
     212Const IPPORT_RESERVED = 1024
     213
     214' Link numbers
     215Const IMPLINK_IP = 155
     216Const IMPLINK_LOWEXPER = 156
     217Const IMPLINK_HIGHEXPER = 158
     218
     219#ifndef s_addr
     220#define s_addr
     221' Internet address (old style... should be updated)
     222Class in_addr
     223Public
     224/*
     225    Union S_un
     226        S_un_b As Type
     227            s_b1 As Byte
     228            s_b2 As Byte
     229            s_b3 As Byte
     230            s_b4 As Byte
     231        End Type
     232        S_un_w As Type
     233            s_w1 As Word
     234            s_w2 As Word
     235        End Type
     236        S_addr As DWord
     237    End Union
     238*/
     239    s_addr As DWord
     240
     241    Function s_host() As Byte
     242        Return GetByte(VarPtr(s_addr) + 1)
     243    End Function
     244
     245    Sub s_host(h As Byte)
     246        Return SetByte(VarPtr(s_addr) + 2, h)
     247    End Sub
     248
     249    Function s_net() As Byte
     250        Return GetByte(VarPtr(s_addr) + 0)
     251    End Function
     252
     253    Sub s_net(n As Byte)
     254        Return SetByte(VarPtr(s_addr) + 0, n)
     255    End Sub
     256
     257    Function s_imp() As Word
     258        Return GetWord(VarPtr(s_addr) + 1)
     259    End Function
     260
     261    Sub s_imp(i As Word)
     262        Return SetWord(VarPtr(s_addr) + 1, i)
     263    End Sub
     264
     265    Function s_impno() As Byte
     266        Return GetByte(VarPtr(s_addr) + 3)
     267    End Function
     268
     269    Sub s_impno(i As Byte)
     270        Return SetByte(VarPtr(s_addr) + 3, i)
     271    End Sub
     272
     273    Function s_lh() As Byte
     274        Return GetByte(VarPtr(s_addr) + 2)
     275    End Function
     276
     277    Sub s_lh(l As Byte)
     278        Return SetByte(VarPtr(s_addr) + 2, l)
     279    End Sub
     280End Class
     281#endif
     282
     283Const IN_CLASSA(i) = (((i) As DWord And &h80000000) = 0)
     284Const IN_CLASSA_NET = &hff000000
     285Const IN_CLASSA_NSHIFT = 24
     286Const IN_CLASSA_HOST = &h00ffffff
     287Const IN_CLASSA_MAX = 128
     288
     289Const IN_CLASSB(i) = (((i) As DWord & &hc0000000) = &h80000000)
     290Const IN_CLASSB_NET= &hffff0000
     291Const IN_CLASSB_NSHIFT = 16
     292Const IN_CLASSB_HOST = &h0000ffff
     293Const IN_CLASSB_MAX = 65536
     294
     295Const IN_CLASSC(i) = (((i) As DWord And &he0000000) = &hc0000000)
     296Const IN_CLASSC_NET = &hffffff00
     297Const IN_CLASSC_NSHIFT = 8
     298Const IN_CLASSC_HOST = &h000000ff
     299
     300Const IN_CLASSD(i) = (((i) As DWord And &hf0000000) = &he0000000)
     301Const IN_CLASSD_NET  = &hf0000000
     302Const IN_CLASSD_NSHIFT = 28
     303Const IN_CLASSD_HOST = &h0fffffff
     304Const IN_MULTICAST(i) = IN_CLASSD(i)
     305
     306Const INADDR_ANY = &h00000000 As DWord
     307Const INADDR_LOOPBACK = &h7f000001
     308Const INADDR_BROADCAST = &hffffffff As DWord
     309Const INADDR_NONE = &hffffffff
     310
     311Const ADDR_ANY = INADDR_ANY
     312
     313' Socket address, internet style.
     314Type sockaddr_in
     315    sin_family As Integer
    183316    sin_port As Word
    184     sin_addr As DWord
    185     sin_zero[7] As Byte
    186 End Type
    187 
    188 
    189 '-------------
    190 ' WinSock API
    191 '-------------
    192 
    193 Declare Function closesocket Lib "ws2_32.dll" (s As SOCKET) As Long
    194 Declare Function connect Lib "ws2_32.dll" (s As SOCKET, ByRef name As Any, namelen As Long) As Long
    195 Declare Function gethostbyname Lib "ws2_32.dll" (name As BytePtr) As *HOSTENT
    196 Declare Function getservbyname Lib "ws2_32.dll" (name As BytePtr, proto As BytePtr) As *SERVENT
    197 Declare Function htonl Lib "ws2_32.dll" (hostlong As DWord) As DWord
    198 Declare Function htons Lib "ws2_32.dll" (hostshort As Word) As Word
    199 Declare Function recv Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long) As Long
    200 Declare Function send Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long) As Long
    201 
    202 Const SD_RECEIVE = 0
    203 Const SD_SEND =    1
    204 Const SD_BOTH =    2
    205 Declare Function shutdown Lib "ws2_32.dll" (s As SOCKET, how As Long) As Long
    206 
    207 Const SOCK_STREAM =    1
    208 Const SOCK_DGRAM =     2
    209 Const SOCK_RAW =       3
    210 Const SOCK_RDM =       4
    211 Const SOCK_SEQPACKET = 5
    212 Declare Function socket Lib "ws2_32.dll" (af As Long, sokettype As Long, protocol As Long) As SOCKET
    213 
    214 Declare Function WSACleanup Lib "ws2_32.dll" () As Integer
     317    sin_addr As in_addr
     318    sin_zero[ELM(8)] As Byte
     319End Type
    215320
    216321Const WSADESCRIPTION_LEN = 256
    217 Const WSASYS_STATUS_LEN  = 128
     322Const WSASYS_STATUS_LEN = 128
     323
    218324Type WSADATA
    219325    wVersion As Word
    220326    wHighVersion As Word
     327#ifdef _WIN64
     328    iMaxSockets As Word
     329    iMaxUdpDg As Word
     330    lpVendorInfo As *Byte
     331    szDescription[WSADESCRIPTION_LEN] As Byte
     332    szSystemStatus[WSASYS_STATUS_LEN] As Byte
     333#else
    221334    szDescription[WSADESCRIPTION_LEN] As Byte
    222335    szSystemStatus[WSASYS_STATUS_LEN] As Byte
    223336    iMaxSockets As Word
    224337    iMaxUdpDg As Word
    225     lpVendorInfo As BytePtr
    226 End Type
    227 Declare Function WSAStartup Lib "ws2_32.dll" (wVersionRequested As Word, ByRef lpWSAData As WSADATA) As Long
    228 
    229 
    230 Declare Function accept Lib "ws2_32.dll" (s As SOCKET, ByRef addr As SOCKADDR_IN, ByVal addrlen As Long) As SOCKET
    231 Declare Function bind Lib "ws2_32.dll" (s As SOCKET, ByRef sName As SOCKADDR_IN, ByVal namelen As Long) As Long
    232 Declare Function ioctlsocket Lib "ws2_32.dll" (s As SOCKET, ByVal cmd As Long, argp As DWord) As Long
    233 Declare Function listen Lib "ws2_32.dll" (s As SOCKET, ByVal backlog As Long) As Long
    234 
    235 Declare Function recvfrom Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long, ByRef from As SOCKADDR_IN, fromlen As Long) As Long
    236 Declare Function sendto Lib "ws2_32.dll" (s As SOCKET, buf As BytePtr, length As Long, flags As Long, ByRef sTo As SOCKADDR_IN, tolen As Long) As Long
    237 
    238 Const INADDR_ANY = &h0
    239 
    240 Declare Function htons Lib "ws2_32.dll" (netshort As Word) As Word
    241 Declare Function htonl Lib "ws2_32.dll" (netshort As DWord)  As DWord
    242 Declare Function ntohs Lib "ws2_32.dll" (netshort As Word) As Word
    243 Declare Function ntohl Lib "ws2_32.dll" (netshort As DWord)  As DWord
    244 
    245 #endif '_INC_WINSOCK2
     338    lpVendorInfo As *Byte
     339#endif
     340End Type
     341
     342TypeDef LPWSADATA = *WSADATA
     343
     344' Definitions related to sockets: types, address families, options,  taken from the BSD file sys/socket.h.
     345
     346Const INVALID_SOCKET = (Not 0) As ULONG_PTR
     347Const SOCKET_ERROR = (-1)
     348
     349Const FROM_PROTOCOL_INFO = (-1)
     350
     351' Types
     352Const SOCK_STREAM = 1
     353Const SOCK_DGRAM = 2
     354Const SOCK_RAW = 3
     355Const SOCK_RDM = 4
     356Const SOCK_SEQPACKET = 5
     357
     358' Option flags per-socket.
     359Const SO_DEBUG = &h0001
     360Const SO_ACCEPTCONN = &h0002
     361Const SO_REUSEADDR = &h0004
     362Const SO_KEEPALIVE = &h0008
     363Const SO_DONTROUTE = &h0010
     364Const SO_BROADCAST = &h0020
     365Const SO_USELOOPBACK = &h0040
     366Const SO_LINGER = &h0080
     367Const SO_OOBINLINE = &h0100
     368
     369Const SO_DONTLINGER = ((Not SO_LINGER) As Long)
     370Const SO_EXCLUSIVEADDRUSE = ((Not SO_REUSEADDR) As Long)
     371
     372' Additional options.
     373Const SO_SNDBUF = &h1001
     374Const SO_RCVBUF = &h1002
     375Const SO_SNDLOWAT = &h1003
     376Const SO_RCVLOWAT = &h1004
     377Const SO_SNDTIMEO = &h1005
     378Const SO_RCVTIMEO = &h1006
     379Const SO_ERROR = &h1007
     380Const SO_TYPE = &h1008
     381
     382' WinSock 2 extension -- new options
     383Const SO_GROUP_ID = &h2001
     384Const SO_GROUP_PRIORITY = &h2002
     385Const SO_MAX_MSG_SIZE = &h2003
     386Const SO_PROTOCOL_INFOA = &h2004
     387Const SO_PROTOCOL_INFOW = &h2005
     388#ifdef UNICODE
     389Const SO_PROTOCOL_INFO = SO_PROTOCOL_INFOW
     390#else
     391Const SO_PROTOCOL_INFO = SO_PROTOCOL_INFOA
     392#endif /* UNICODE */
     393Const PVD_CONFIG = &h3001
     394Const SO_CONDITIONAL_ACCEPT = &h3002
     395
     396' TCP options.
     397Const TCP_NODELAY = &h0001
     398
     399' Address families.
     400Const AF_UNSPEC = 0
     401Const AF_UNIX = 1
     402Const AF_INET = 2
     403Const AF_IMPLINK = 3
     404Const AF_PUP = 4
     405Const AF_CHAOS = 5
     406Const AF_NS = 6
     407Const AF_IPX = AF_NS
     408Const AF_ISO = 7
     409Const AF_OSI = AF_ISO
     410Const AF_ECMA = 8
     411Const AF_DATAKIT = 9
     412Const AF_CCITT = 10
     413Const AF_SNA = 11
     414Const AF_DECnet = 12
     415Const AF_DLI = 13
     416Const AF_LAT = 14
     417Const AF_HYLINK = 15
     418Const AF_APPLETALK = 16
     419Const AF_NETBIOS = 17
     420Const AF_VOICEVIEW = 18
     421Const AF_FIREFOX = 19
     422Const AF_UNKNOWN1 = 20
     423Const AF_BAN = 21
     424Const AF_ATM = 22
     425Const AF_INET6 = 23
     426Const AF_CLUSTER = 24
     427Const AF_12844 = 25
     428Const AF_IRDA = 26
     429Const AF_NETDES = 28
     430
     431Const AF_TCNPROCESS = 29
     432Const AF_TCNMESSAGE = 30
     433Const AF_ICLFXBM = 31
     434
     435Const AF_MAX = 32
     436
     437' Structure used by kernel to store most addresses.
     438Type sockaddr
     439    sa_family As Word
     440    sa_data[ELM(14)] As Byte
     441End Type
     442
     443' Portable socket structure (RFC 2553).
     444
     445' Desired design of maximum size and alignment.
     446' These are implementation specific.
     447Const _SS_MAXSIZE = 128 ' Maximum size.
     448Const _SS_ALIGNSIZE = (SizeOf (Int64)) 'Desired alignment.
     449
     450' Definitions used for sockaddr_storage structure paddings design.
     451Const _SS_PAD1SIZE = (_SS_ALIGNSIZE - SizeOf (Integer))
     452Const _SS_PAD2SIZE = (_SS_MAXSIZE - (SizeOf (Integer) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
     453
     454Type sockaddr_storage
     455    ss_family As Integer
     456    __ss_pad1[ELM(_SS_PAD1SIZE)] As Byte
     457    __ss_align As Int64
     458    __ss_pad2[ELM(_SS_PAD2SIZE)] As Byte
     459End Type
     460
     461Type sockproto
     462    sp_family As Word
     463    sp_protocol As Word
     464End Type
     465
     466' Protocol families, same as address families for now.
     467Const PF_UNSPEC = AF_UNSPEC
     468Const PF_UNIX = AF_UNIX
     469Const PF_INET = AF_INET
     470Const PF_IMPLINK = AF_IMPLINK
     471Const PF_PUP = AF_PUP
     472Const PF_CHAOS = AF_CHAOS
     473Const PF_NS = AF_NS
     474Const PF_IPX = AF_IPX
     475Const PF_ISO = AF_ISO
     476Const PF_OSI = AF_OSI
     477Const PF_ECMA = AF_ECMA
     478Const PF_DATAKIT = AF_DATAKIT
     479Const PF_CCITT = AF_CCITT
     480Const PF_SNA = AF_SNA
     481Const PF_DECnet = AF_DECnet
     482Const PF_DLI = AF_DLI
     483Const PF_LAT = AF_LAT
     484Const PF_HYLINK = AF_HYLINK
     485Const PF_APPLETALK = AF_APPLETALK
     486Const PF_VOICEVIEW = AF_VOICEVIEW
     487Const PF_FIREFOX = AF_FIREFOX
     488Const PF_UNKNOWN1 = AF_UNKNOWN1
     489Const PF_BAN = AF_BAN
     490Const PF_ATM = AF_ATM
     491Const PF_INET6 = AF_INET6
     492
     493Const PF_MAX = AF_MAX
     494
     495' Structure used for manipulating linger option.
     496Type linger
     497    l_onoff As Word
     498    l_linger As Word
     499End Type
     500
     501' Level number for (get/set)sockopt() to apply to socket itself.
     502Const SOL_SOCKET = &hffff
     503
     504' Maximum queue length specifiable by listen.
     505Const SOMAXCONN = &h7fffffff
     506
     507Const MSG_OOB = &h1
     508Const MSG_PEEK = &h2
     509Const MSG_DONTROUTE = &h4
     510Const MSG_WAITALL = &h8
     511
     512Const MSG_PARTIAL = &h8000
     513
     514' WinSock 2 extension -- new flags for WSASend(), WSASendTo(), WSARecv() and
     515'                          WSARecvFrom()
     516Const MSG_INTERRUPT = &h10
     517
     518Const MSG_MAXIOVLEN = 16
     519
     520' Define constant based on rfc883, used by gethostbyxxxx() calls.
     521Const MAXGETHOSTSTRUCT = 1024
     522
     523' WinSock 2 extension -- bit values and indices for FD_XXX network events
     524Const FD_READ_BIT = 0
     525Const FD_READ = (1 << FD_READ_BIT)
     526
     527Const FD_WRITE_BIT = 1
     528Const FD_WRITE = (1 << FD_WRITE_BIT)
     529
     530Const FD_OOB_BIT = 2
     531Const FD_OOB = (1 << FD_OOB_BIT)
     532
     533Const FD_ACCEPT_BIT = 3
     534Const FD_ACCEPT = (1 << FD_ACCEPT_BIT)
     535
     536Const FD_CONNECT_BIT = 4
     537Const FD_CONNECT = (1 << FD_CONNECT_BIT)
     538
     539Const FD_CLOSE_BIT = 5
     540Const FD_CLOSE = (1 << FD_CLOSE_BIT)
     541
     542Const FD_QOS_BIT = 6
     543Const FD_QOS = (1 << FD_QOS_BIT)
     544
     545Const FD_GROUP_QOS_BIT = 7
     546Const FD_GROUP_QOS = (1 << FD_GROUP_QOS_BIT)
     547
     548Const FD_ROUTING_INTERFACE_CHANGE_BIT = 8
     549Const FD_ROUTING_INTERFACE_CHANGE = (1 << FD_ROUTING_INTERFACE_CHANGE_BIT)
     550
     551Const FD_ADDRESS_LIST_CHANGE_BIT = 9
     552Const FD_ADDRESS_LIST_CHANGE = (1 << FD_ADDRESS_LIST_CHANGE_BIT)
     553
     554Const FD_MAX_EVENTS = 10
     555Const FD_ALL_EVENTS = ((1 << FD_MAX_EVENTS) - 1)
     556
     557#include <api_winerror.sbp>
     558
     559' Compatibility macros.
     560
     561'Const h_errno = WSAGetLastError()
     562Const HOST_NOT_FOUND = WSAHOST_NOT_FOUND
     563Const TRY_AGAIN = WSATRY_AGAIN
     564Const NO_RECOVERY = WSANO_RECOVERY
     565Const NO_DATA = WSANO_DATA
     566Const WSANO_ADDRESS = WSANO_DATA
     567Const NO_ADDRESS = WSANO_ADDRESS
     568
     569' WinSock 2 extension -- new error codes and type definition
     570
     571'#ifdef _WIN32
     572
     573TypeDef WSAEVENT = HANDLE
     574TypeDef LPWSAEVENT = *HANDLE
     575TypeDef WSAOVERLAPPED = OVERLAPPED
     576TypeDef LPWSAOVERLAPPED = *OVERLAPPED
     577
     578Const WSA_IO_PENDING = (ERROR_IO_PENDING)
     579Const WSA_IO_INCOMPLETE = (ERROR_IO_INCOMPLETE)
     580Const WSA_INVALID_HANDLE = (ERROR_INVALID_HANDLE)
     581Const WSA_INVALID_PARAMETER = (ERROR_INVALID_PARAMETER)
     582Const WSA_NOT_ENOUGH_MEMORY = (ERROR_NOT_ENOUGH_MEMORY)
     583Const WSA_OPERATION_ABORTED = (ERROR_OPERATION_ABORTED)
     584
     585Const WSA_INVALID_EVENT = (0 As WSAEVENT)
     586Const WSA_MAXIMUM_WAIT_EVENTS = (MAXIMUM_WAIT_OBJECTS)
     587Const WSA_WAIT_FAILED = (WAIT_FAILED)
     588Const WSA_WAIT_EVENT_0 = (WAIT_OBJECT_0)
     589Const WSA_WAIT_IO_COMPLETION = (WAIT_IO_COMPLETION)
     590Const WSA_WAIT_TIMEOUT = (WAIT_TIMEOUT)
     591Const WSA_INFINITE = (INFINITE)
     592
     593'#elif defined _WIN16
     594'#endif
     595
     596Type WSABUF
     597    len As DWord
     598    buf As *Byte
     599End Type
     600TypeDef LPWSABUF = *WSABUF
     601
     602#include <qos.ab>
     603
     604Type QOS 'struct _QualityOfService
     605    SendingFlowspec As FLOWSPEC
     606    ReceivingFlowspec As FLOWSPEC
     607    ProviderSpecific As WSABUF
     608End Type
     609TypeDef LPQOS = *QOS
     610
     611' WinSock 2 extension -- manifest constants for return values of the condition function
     612Const CF_ACCEPT = &h0000
     613Const CF_REJECT = &h0001
     614Const CF_DEFER = &h0002
     615
     616' WinSock 2 extension -- manifest constants for shutdown()
     617Const SD_RECEIVE = &h00
     618Const SD_SEND = &h01
     619Const SD_BOTH = &h02
     620
     621' WinSock 2 extension -- data type and manifest constants for socket groups
     622TypeDef GROUP = DWord
     623
     624Const SG_UNCONSTRAINED_GROUP = &h01
     625Const SG_CONSTRAINED_GROUP = &h02
     626
     627' WinSock 2 extension -- data type for WSAEnumNetworkEvents()
     628Type WSANETWORKEVENTS
     629    lNetworkEvents As Long
     630    iErrorCode[ELM(FD_MAX_EVENTS)] As Long
     631End Type
     632TypeDef LPWSANETWORKEVENTS = *WSANETWORKEVENTS
     633
     634' WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
     635' manifest constants
     636
     637Const MAX_PROTOCOL_CHAIN = 7
     638
     639Const BASE_PROTOCOL = 1
     640Const LAYERED_PROTOCOL = 0
     641
     642Type WSAPROTOCOLCHAIN
     643    ChainLen As Long
     644    ChainEntries[ELM(MAX_PROTOCOL_CHAIN)] As DWord
     645End Type
     646TypeDef LPWSAPROTOCOLCHAIN = *WSAPROTOCOLCHAIN
     647
     648Const WSAPROTOCOL_LEN = 255
     649
     650Type WSAPROTOCOL_INFOA
     651    dwServiceFlags1 As DWord
     652    dwServiceFlags2 As DWord
     653    dwServiceFlags3 As DWord
     654    dwServiceFlags4 As DWord
     655    dwProviderFlags As DWord
     656    ProviderId As GUID
     657    dwCatalogEntryId As DWord
     658    ProtocolChain As WSAPROTOCOLCHAIN
     659    iVersion As Long
     660    iAddressFamily As Long
     661    iMaxSockAddr As Long
     662    iMinSockAddr As Long
     663    iSocketType As Long
     664    iProtocol As Long
     665    iProtocolMaxOffset As Long
     666    iNetworkByteOrder As Long
     667    iSecurityScheme As Long
     668    dwMessageSize As DWord
     669    dwProviderReserved As DWord
     670    szProtocol[WSAPROTOCOL_LEN] As Byte
     671End Type
     672TypeDef LPWSAPROTOCOL_INFOA = *WSAPROTOCOL_INFOA
     673
     674Type WSAPROTOCOL_INFOW
     675    dwServiceFlags1 As DWord
     676    dwServiceFlags2 As DWord
     677    dwServiceFlags3 As DWord
     678    dwServiceFlags4 As DWord
     679    dwProviderFlags As DWord
     680    ProviderId As GUID
     681    dwCatalogEntryId As DWord
     682    ProtocolChain As WSAPROTOCOLCHAIN
     683    iVersion As Long
     684    iAddressFamily As Long
     685    iMaxSockAddr As Long
     686    iMinSockAddr As Long
     687    iSocketType As Long
     688    iProtocol As Long
     689    iProtocolMaxOffset As Long
     690    iNetworkByteOrder As Long
     691    iSecurityScheme As Long
     692    dwMessageSize As DWord
     693    dwProviderReserved As DWord
     694    szProtocol[WSAPROTOCOL_LEN] As WCHAR
     695End Type
     696TypeDef LPWSAPROTOCOL_INFOW = *WSAPROTOCOL_INFOW
     697
     698#ifdef UNICODE
     699TypeDef WSAPROTOCOL_INFO = WSAPROTOCOL_INFOW
     700TypeDef LPWSAPROTOCOL_INFO = LPWSAPROTOCOL_INFOW
     701#else
     702TypeDef WSAPROTOCOL_INFO = WSAPROTOCOL_INFOA
     703TypeDef LPWSAPROTOCOL_INFO = LPWSAPROTOCOL_INFOA
     704#endif
     705
     706' Flag bit definitions for dwProviderFlags
     707Const PFL_MULTIPLE_PROTO_ENTRIES = &h00000001
     708Const PFL_RECOMMENDED_PROTO_ENTRY = &h00000002
     709Const PFL_HIDDEN = &h00000004
     710Const PFL_MATCHES_PROTOCOL_ZERO = &h00000008
     711
     712' Flag bit definitions for dwServiceFlags1
     713Const XP1_CONNECTIONLESS = &h00000001
     714Const XP1_GUARANTEED_DELIVERY = &h00000002
     715Const XP1_GUARANTEED_ORDER = &h00000004
     716Const XP1_MESSAGE_ORIENTED = &h00000008
     717Const XP1_PSEUDO_STREAM = &h00000010
     718Const XP1_GRACEFUL_CLOSE = &h00000020
     719Const XP1_EXPEDITED_DATA = &h00000040
     720Const XP1_CONNECT_DATA = &h00000080
     721Const XP1_DISCONNECT_DATA = &h00000100
     722Const XP1_SUPPORT_BROADCAST = &h00000200
     723Const XP1_SUPPORT_MULTIPOINT = &h00000400
     724Const XP1_MULTIPOINT_CONTROL_PLANE = &h00000800
     725Const XP1_MULTIPOINT_DATA_PLANE = &h00001000
     726Const XP1_QOS_SUPPORTED = &h00002000
     727Const XP1_INTERRUPT = &h00004000
     728Const XP1_UNI_SEND = &h00008000
     729Const XP1_UNI_RECV = &h00010000
     730Const XP1_IFS_HANDLES = &h00020000
     731Const XP1_PARTIAL_MESSAGE = &h00040000
     732
     733Const BIGENDIAN = &h0000
     734Const LITTLEENDIAN = &h0001
     735
     736Const SECURITY_PROTOCOL_NONE = &h0000
     737
     738' WinSock 2 extension -- manifest constants for WSAJoinLeaf()
     739Const JL_SENDER_ONLY = &h01
     740Const JL_RECEIVER_ONLY = &h02
     741Const JL_BOTH = &h04
     742
     743' WinSock 2 extension -- manifest constants for WSASocket()
     744Const WSA_FLAG_OVERLAPPED = &h01
     745Const WSA_FLAG_MULTIPOINT_C_ROOT = &h02
     746Const WSA_FLAG_MULTIPOINT_C_LEAF = &h04
     747Const WSA_FLAG_MULTIPOINT_D_ROOT = &h08
     748Const WSA_FLAG_MULTIPOINT_D_LEAF = &h10
     749
     750' WinSock 2 extension -- manifest constants for WSAIoctl()
     751Const IOC_UNIX = &h00000000
     752Const IOC_WS2 = &h08000000
     753Const IOC_PROTOCOL = &h10000000
     754Const IOC_VENDOR = &h18000000
     755
     756Const _WSAIO(x, y) = (IOC_VOID Or (x) Or (y))
     757Const _WSAIOR(x, y) = (IOC_OUT Or (x) Or (y))
     758Const _WSAIOW(x, y) = (IOC_IN Or (x) Or (y))
     759Const _WSAIORW(x, y) = (IOC_INOUT Or (x) Or (y))
     760
     761Const SIO_ASSOCIATE_HANDLE = _WSAIOW(IOC_WS2, 1)
     762Const SIO_ENABLE_CIRCULAR_QUEUEING = _WSAIO(IOC_WS2, 2)
     763Const SIO_FIND_ROUTE = _WSAIOR(IOC_WS2, 3)
     764Const SIO_FLUSH = _WSAIO(IOC_WS2, 4)
     765Const SIO_GET_BROADCAST_ADDRESS = _WSAIOR(IOC_WS2, 5)
     766Const SIO_GET_EXTENSION_FUNCTION_POINTER = _WSAIORW(IOC_WS2, 6)
     767Const SIO_GET_QOS = _WSAIORW(IOC_WS2, 7)
     768Const SIO_GET_GROUP_QOS = _WSAIORW(IOC_WS2, 8)
     769Const SIO_MULTIPOINT_LOOPBACK = _WSAIOW(IOC_WS2, 9)
     770Const SIO_MULTICAST_SCOPE = _WSAIOW(IOC_WS2, 10)
     771Const SIO_SET_QOS = _WSAIOW(IOC_WS2, 11)
     772Const SIO_SET_GROUP_QOS = _WSAIOW(IOC_WS2, 12)
     773Const SIO_TRANSLATE_HANDLE = _WSAIORW(IOC_WS2, 13)
     774Const SIO_ROUTING_INTERFACE_QUERY = _WSAIORW(IOC_WS2, 20)
     775Const SIO_ROUTING_INTERFACE_CHANGE = _WSAIOW(IOC_WS2, 21)
     776Const SIO_ADDRESS_LIST_QUERY = _WSAIOR(IOC_WS2, 22)
     777Const SIO_ADDRESS_LIST_CHANGE = _WSAIO(IOC_WS2, 23)
     778Const SIO_QUERY_TARGET_PNP_HANDLE = _WSAIOR(IOC_WS2, 24)
     779Const SIO_ADDRESS_LIST_SORT = _WSAIORW(IOC_WS2, 25)
     780
     781' WinSock 2 extensions -- data types for the condition function in
     782' WSAAccept() and overlapped I/O completion routine.
     783
     784TypeDef LPCONDITIONPROC = *Function(
     785    ByRef CallerId As WSABUF,
     786    ByRef CallerData As WSABUF,
     787    ByRef lpSQOS As QOS,
     788    ByRef lpGQOS As QOS,
     789    ByRef lpCalleeId As WSABUF,
     790    ByRef lpCalleeData As WSABUF,
     791    ByRef g As GROUP,
     792    dwCallbackData As ULONG_PTR
     793) As Long
     794
     795TypeDef LPWSAOVERLAPPED_COMPLETION_ROUTINE = *Sub(
     796    dwError As DWord,
     797    cbTransferred As DWord,
     798    ByRef Overlapped As WSAOVERLAPPED,
     799    dwFlags As DWord)
     800
     801' WinSock 2 extension -- manifest constants and associated structures
     802' for WSANSPIoctl()
     803Const SIO_NSP_NOTIFY_CHANGE = _WSAIOW(IOC_WS2, 25)
     804
     805Const Enum WSACOMPLETIONTYPE
     806    NSP_NOTIFY_IMMEDIATELY = 0
     807    NSP_NOTIFY_HWND
     808    NSP_NOTIFY_EVENT
     809    NSP_NOTIFY_PORT
     810    NSP_NOTIFY_APC
     811End Enum
     812
     813TypeDef PWSACOMPLETIONTYPE = *WSACOMPLETIONTYPE
     814TypeDef LPWSACOMPLETIONTYPE = *WSACOMPLETIONTYPE
     815
     816Type _System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     817    hWnd As HWND
     818    uMsg As DWord
     819    context As WPARAM
     820End Type
     821
     822Type _System_WinSock_WSACOMPLETION_EVENT
     823    lpOverlapped As LPWSAOVERLAPPED
     824End Type
     825
     826Type _System_WinSock_WSACOMPLETION_APC
     827    lpOverlapped As LPWSAOVERLAPPED
     828    lpfnCompletionProc As LPWSAOVERLAPPED_COMPLETION_ROUTINE
     829End Type
     830
     831Type _System_WinSock_WSACOMPLETION_PORT
     832    lpOverlapped As LPWSAOVERLAPPED
     833    hPort As HANDLE
     834    Key As ULONG_PTR
     835End Type
     836
     837Class WSACOMPLETION
     838Public
     839    Type_ As WSACOMPLETIONTYPE
     840/*
     841    Parameters As Union
     842        WindowMessage As _System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     843        Event As _System_WinSock_WSACOMPLETION_EVENT
     844        Apc As _System_WinSock_WSACOMPLETION_APC
     845        Port As _System_WinSock_WSACOMPLETION_PORT
     846    End Union
     847*/
     848    Port As _System_WinSock_WSACOMPLETION_PORT
     849
     850    Function WindowMessage() As _System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     851        Dim p As *_System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     852        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     853        Return p[0]
     854    End Function
     855
     856    Sub WindowMessage(w As _System_WinSock_WSACOMPLETION_WINDOWMESSAGE)
     857        Dim p As *_System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     858        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_WINDOWMESSAGE
     859        p[0] = w
     860    End Sub
     861
     862    Function Event() As _System_WinSock_WSACOMPLETION_EVENT
     863        Dim p As *_System_WinSock_WSACOMPLETION_EVENT
     864        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_EVENT
     865        Return p[0]
     866    End Function
     867
     868    Sub Event(e As _System_WinSock_WSACOMPLETION_EVENT)
     869        Dim p As *_System_WinSock_WSACOMPLETION_EVENT
     870        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_EVENT
     871        p[0] = e
     872    End Sub
     873
     874    Function Apc() As _System_WinSock_WSACOMPLETION_APC
     875        Dim p As *_System_WinSock_WSACOMPLETION_APC
     876        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_APC
     877        Return p[0]
     878    End Function
     879
     880    Sub Apc(a As _System_WinSock_WSACOMPLETION_APC)
     881        Dim p As *_System_WinSock_WSACOMPLETION_APC
     882        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_APC
     883        p[0] = a
     884    End Sub
     885/*
     886    Function Port() As _System_WinSock_WSACOMPLETION_PORT
     887        Dim p As *_System_WinSock_WSACOMPLETION_PORT
     888        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_PORT
     889        Return p[0]
     890    End Function
     891
     892    Sub Port(p As _System_WinSock_WSACOMPLETION_PORT)
     893        Dim p As *_System_WinSock_WSACOMPLETION_PORT
     894        p = VarPtr(Port) As *_System_WinSock_WSACOMPLETION_PORT
     895        p[0] = p
     896    End Sub
     897*/
     898End Class
     899
     900TypeDef PWSACOMPLETION = *WSACOMPLETION
     901TypeDef LPWSACOMPLETION = *WSACOMPLETION
     902
     903' WinSock 2 extension -- manifest constants for SIO_TRANSLATE_HANDLE ioctl
     904Const TH_NETDEV = &h00000001
     905Const TH_TAPI = &h00000002
     906
     907TypeDef SOCKADDR = sockaddr
     908TypeDef PSOCKADDR = *sockaddr
     909TypeDef LPSOCKADDR = *sockaddr
     910
     911TypeDef SOCKADDR_STORAGE = sockaddr_storage
     912TypeDef PSOCKADDR_STORAGE = *sockaddr_storage
     913TypeDef LPSOCKADDR_STORAGE = *sockaddr_storage
     914
     915' Manifest constants and type definitions related to name resolution and
     916' registration (RNR) API
     917
     918#ifndef _tagBLOB_DEFINED
     919#define _tagBLOB_DEFINED
     920#define _BLOB_DEFINED
     921#define _LPBLOB_DEFINED
     922Type BLOB
     923    cbSize As DWord
     924#ifdef MIDL_PASS
     925    [size_is(cbSize)] pBlobData As *Byte
     926#else
     927    pBlobData As *Byte
     928#endif
     929End Type
     930TypeDef LPBLOB = *BLOB
     931#endif
     932
     933' Service Install Flags
     934Const SERVICE_MULTIPLE = (&h00000001)
     935
     936' Name Spaces
     937
     938Const NS_ALL = (0)
     939
     940Const NS_SAP = (1)
     941Const NS_NDS = (2)
     942Const NS_PEER_BROWSE = (3)
     943Const NS_SLP = (5)
     944Const NS_DHCP = (6)
     945
     946Const NS_TCPIP_LOCAL = (10)
     947Const NS_TCPIP_HOSTS = (11)
     948Const NS_DNS = (12)
     949Const NS_NETBT = (13)
     950Const NS_WINS = (14)
     951Const NS_NLA = (15)
     952
     953Const NS_NBP = (20)
     954
     955Const NS_MS = (30)
     956Const NS_STDA = (31)
     957Const NS_NTDS = (32)
     958
     959Const NS_X500 = (40)
     960Const NS_NIS = (41)
     961Const NS_NISPLUS = (42)
     962
     963Const NS_WRQ = (50)
     964
     965Const NS_NETDES = (60)
     966
     967' Resolution flags for WSAGetAddressByName().
     968Const RES_UNUSED_1 = (&h00000001)
     969Const RES_FLUSH_CACHE = (&h00000002)
     970#ifndef RES_SERVICE
     971#define RES_SERVICE
     972Const RES_SERVICE = (&h00000004)
     973#endif /* RES_SERVICE */
     974
     975' Well known value names for Service Types
     976
     977Const SERVICE_TYPE_VALUE_IPXPORTA = "IpxSocket"
     978'Const SERVICE_TYPE_VALUE_IPXPORTW = L"IpxSocket"
     979Const SERVICE_TYPE_VALUE_SAPIDA = "SapId"
     980'Const SERVICE_TYPE_VALUE_SAPIDW = L"SapId"
     981
     982Const SERVICE_TYPE_VALUE_TCPPORTA = "TcpPort"
     983'Const SERVICE_TYPE_VALUE_TCPPORTW = L"TcpPort"
     984
     985Const SERVICE_TYPE_VALUE_UDPPORTA = "UdpPort"
     986'Const SERVICE_TYPE_VALUE_UDPPORTW = L"UdpPort"
     987
     988Const SERVICE_TYPE_VALUE_OBJECTIDA = "ObjectId"
     989'Const SERVICE_TYPE_VALUE_OBJECTIDW = L"ObjectId"
     990
     991#ifdef UNICODE
     992/*
     993Const SERVICE_TYPE_VALUE_SAPID = SERVICE_TYPE_VALUE_SAPIDW
     994Const SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTW
     995Const SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTW
     996Const SERVICE_TYPE_VALUE_OBJECTID = SERVICE_TYPE_VALUE_OBJECTIDW
     997*/
     998#else
     999
     1000Const SERVICE_TYPE_VALUE_SAPID = SERVICE_TYPE_VALUE_SAPIDA
     1001Const SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTA
     1002Const SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTA
     1003Const SERVICE_TYPE_VALUE_OBJECTID = SERVICE_TYPE_VALUE_OBJECTIDA
     1004
     1005#endif
     1006
     1007#ifndef __CSADDR_DEFINED__
     1008#define __CSADDR_DEFINED__
     1009
     1010' SockAddr Information
     1011Type SOCKET_ADDRESS
     1012    lpSockaddr As LPSOCKADDR
     1013    iSockaddrLength As Long
     1014End Type
     1015TypeDef PSOCKET_ADDRESS = *SOCKET_ADDRESS
     1016TypeDef LPSOCKET_ADDRESS = *SOCKET_ADDRESS
     1017
     1018' CSAddr Information
     1019Type CSADDR_INFO
     1020    LocalAddr As SOCKET_ADDRESS
     1021    RemoteAddr As SOCKET_ADDRESS
     1022    iSocketType As Long
     1023    iProtocol As Long
     1024End Type
     1025TypeDef PCSADDR_INFO = *CSADDR_INFO
     1026TypeDef LPCSADDR_INFO = *CSADDR_INFO
     1027#endif
     1028
     1029' Address list returned via SIO_ADDRESS_LIST_QUERY
     1030Type SOCKET_ADDRESS_LIST
     1031    iAddressCount As Long
     1032    Address[ELM(1)] As SOCKET_ADDRESS
     1033End Type
     1034TypeDef LPSOCKET_ADDRESS_LIST = *SOCKET_ADDRESS_LIST
     1035
     1036' Address Family/Protocol Tuples
     1037Type AFPROTOCOLS
     1038    iAddressFamily As Long
     1039    iProtocol As Long
     1040End Type
     1041TypeDef PAFPROTOCOLS = *AFPROTOCOLS
     1042TypeDef LPAFPROTOCOLS = *AFPROTOCOLS
     1043
     1044' Client Query API Typedefs
     1045
     1046' The comparators
     1047Const Enum WSAECOMPARATOR
     1048    COMP_EQUAL = 0
     1049    COMP_NOTLESS
     1050End Enum
     1051TypeDef PWSAECOMPARATOR = *WSAECOMPARATOR
     1052TypeDef LPWSAECOMPARATOR = *WSAECOMPARATOR
     1053
     1054Type WSAVERSION
     1055    dwVersion As DWord
     1056    ecHow As WSAECOMPARATOR
     1057End Type
     1058TypeDef PWSAVERSION = *WSAVERSION
     1059TypeDef LPWSAVERSION = *WSAVERSION
     1060
     1061Type WSAQUERYSETA
     1062    dwSize As DWord
     1063    lpszServiceInstanceName As LPSTR
     1064    lpServiceClassId As *GUID
     1065    lpVersion As LPWSAVERSION
     1066    lpszComment As LPSTR
     1067    dwNameSpace As DWord
     1068    lpNSProviderId As *GUID
     1069    lpszContext As LPSTR
     1070    dwNumberOfProtocols As DWord
     1071    lpafpProtocols As LPAFPROTOCOLS
     1072    lpszQueryString As LPSTR
     1073    dwNumberOfCsAddrs As DWord
     1074    lpcsaBuffer As LPCSADDR_INFO
     1075    dwOutputFlags As DWord
     1076    lpBlob As LPBLOB
     1077End Type
     1078TypeDef PWSAQUERYSETA = *WSAQUERYSETA
     1079TypeDef LPWSAQUERYSETA = *WSAQUERYSETA
     1080
     1081Type WSAQUERYSETW
     1082    dwSize As DWord
     1083    lpszServiceInstanceName As LPWSTR
     1084    lpServiceClassId As *GUID
     1085    lpVersion As LPWSAVERSION
     1086    lpszComment As LPWSTR
     1087    dwNameSpace As DWord
     1088    lpNSProviderId As *GUID
     1089    lpszContext As LPWSTR
     1090    dwNumberOfProtocols As DWord
     1091    lpafpProtocols As LPAFPROTOCOLS
     1092    lpszQueryString As LPWSTR
     1093    dwNumberOfCsAddrs As DWord
     1094    lpcsaBuffer As LPCSADDR_INFO
     1095    dwOutputFlags As DWord
     1096    lpBlob As LPBLOB
     1097End Type
     1098TypeDef PWSAQUERYSETW = *WSAQUERYSETW
     1099TypeDef LPWSAQUERYSETW = *WSAQUERYSETW
     1100
     1101#ifdef UNICODE
     1102TypeDef WSAQUERYSET = WSAQUERYSETW
     1103TypeDef PWSAQUERYSET = PWSAQUERYSETW
     1104TypeDef LPWSAQUERYSET = LPWSAQUERYSETW
     1105#else
     1106TypeDef WSAQUERYSET = WSAQUERYSETA
     1107TypeDef PWSAQUERYSET = PWSAQUERYSETA
     1108TypeDef LPWSAQUERYSET = LPWSAQUERYSETA
     1109#endif
     1110
     1111Const LUP_DEEP = &h0001
     1112Const LUP_CONTAINERS = &h0002
     1113Const LUP_NOCONTAINERS = &h0004
     1114Const LUP_NEAREST = &h0008
     1115Const LUP_RETURN_NAME = &h0010
     1116Const LUP_RETURN_TYPE = &h0020
     1117Const LUP_RETURN_VERSION = &h0040
     1118Const LUP_RETURN_COMMENT = &h0080
     1119Const LUP_RETURN_ADDR = &h0100
     1120Const LUP_RETURN_BLOB = &h0200
     1121Const LUP_RETURN_ALIASES = &h0400
     1122Const LUP_RETURN_QUERY_STRING = &h0800
     1123Const LUP_RETURN_ALL = &h0FF0
     1124Const LUP_RES_SERVICE = &h8000
     1125
     1126Const LUP_FLUSHCACHE = &h1000
     1127Const LUP_FLUSHPREVIOUS = &h2000
     1128
     1129' Return flags
     1130Const RESULT_IS_ALIAS = &h0001
     1131Const RESULT_IS_ADDED = &h0010
     1132Const RESULT_IS_CHANGED = &h0020
     1133Const RESULT_IS_DELETED = &h0040
     1134
     1135' Service Address Registration and Deregistration Data Types.
     1136
     1137Const Enum WSAESETSERVICEOP
     1138    RNRSERVICE_REGISTER = 0
     1139    RNRSERVICE_DEREGISTER
     1140    RNRSERVICE_DELETE
     1141End Enum
     1142TypeDef PWSAESETSERVICEOP = *WSAESETSERVICEOP
     1143TypeDef LPWSAESETSERVICEOP = *WSAESETSERVICEOP
     1144
     1145' Service Installation/Removal Data Types.
     1146
     1147Type WSANSCLASSINFOA
     1148    lpszName As LPSTR
     1149    dwNameSpace As DWord
     1150    dwValueType As DWord
     1151    dwValueSize As DWord
     1152    lpValue As VoidPtr
     1153End Type
     1154TypeDef PWSANSCLASSINFOA = *WSANSCLASSINFOA
     1155TypeDef LPWSANSCLASSINFOA = *WSANSCLASSINFOA
     1156
     1157Type WSANSCLASSINFOW
     1158    lpszName As LPWSTR
     1159    dwNameSpace As DWord
     1160    dwValueType As DWord
     1161    dwValueSize As DWord
     1162    lpValue As VoidPtr
     1163End Type
     1164TypeDef PWSANSCLASSINFOW = *WSANSCLASSINFOW
     1165TypeDef LPWSANSCLASSINFOW = *WSANSCLASSINFOW
     1166
     1167#ifdef UNICODE
     1168TypeDef WSANSCLASSINFO = WSANSCLASSINFOW
     1169TypeDef PWSANSCLASSINFO = PWSANSCLASSINFOW
     1170TypeDef LPWSANSCLASSINFO = LPWSANSCLASSINFOW
     1171#else
     1172TypeDef WSANSCLASSINFO = WSANSCLASSINFOA
     1173TypeDef PWSANSCLASSINFO = PWSANSCLASSINFOA
     1174TypeDef LPWSANSCLASSINFO = LPWSANSCLASSINFOA
     1175#endif
     1176
     1177Type WSASERVICECLASSINFOA
     1178    lpServiceClassId As *GUID
     1179    lpszServiceClassName As LPSTR
     1180    dwCount As DWord
     1181    lpClassInfos As LPWSANSCLASSINFOA
     1182End Type
     1183TypeDef PWSASERVICECLASSINFOA = *WSASERVICECLASSINFOA
     1184TypeDef LPWSASERVICECLASSINFOA = *WSASERVICECLASSINFOA
     1185
     1186Type WSASERVICECLASSINFOW
     1187    lpServiceClassId As *GUID
     1188    lpszServiceClassName As LPWSTR
     1189    dwCount As DWord
     1190    lpClassInfos As LPWSANSCLASSINFOA
     1191End Type
     1192TypeDef PWSASERVICECLASSINFOW = *WSASERVICECLASSINFOW
     1193TypeDef LPWSASERVICECLASSINFOW = *WSASERVICECLASSINFOW
     1194
     1195#ifdef UNICODE
     1196TypeDef WSASERVICECLASSINFO = WSASERVICECLASSINFOW
     1197TypeDef PWSASERVICECLASSINFO = PWSASERVICECLASSINFOW
     1198TypeDef LPWSASERVICECLASSINFO = LPWSASERVICECLASSINFOW
     1199#else
     1200TypeDef WSASERVICECLASSINFO = WSASERVICECLASSINFOA
     1201TypeDef PWSASERVICECLASSINFO = PWSASERVICECLASSINFOA
     1202TypeDef LPWSASERVICECLASSINFO = LPWSASERVICECLASSINFOA
     1203#endif
     1204
     1205Type WSANAMESPACE_INFOA
     1206    NSProviderId As GUID
     1207    dwNameSpace As DWord
     1208    fActive As BOOL
     1209    dwVersion As DWord
     1210    lpszIdentifier As LPSTR
     1211End Type
     1212TypeDef PWSANAMESPACE_INFOA = *WSANAMESPACE_INFOA
     1213TypeDef LPWSANAMESPACE_INFOA = *WSANAMESPACE_INFOA
     1214
     1215Type WSANAMESPACE_INFOW
     1216    NSProviderId As GUID
     1217    dwNameSpace As DWord
     1218    fActive As BOOL
     1219    dwVersion As DWord
     1220    lpszIdentifier As LPWSTR
     1221End Type
     1222TypeDef PWSANAMESPACE_INFOW = *WSANAMESPACE_INFOW
     1223TypeDef LPWSANAMESPACE_INFOW = *WSANAMESPACE_INFOW
     1224
     1225#ifdef UNICODE
     1226TypeDef WSANAMESPACE_INFO = WSANAMESPACE_INFOW
     1227TypeDef PWSANAMESPACE_INFO = PWSANAMESPACE_INFOW
     1228TypeDef LPWSANAMESPACE_INFO = LPWSANAMESPACE_INFOW
     1229#else
     1230TypeDef WSANAMESPACE_INFO = WSANAMESPACE_INFOA
     1231TypeDef PWSANAMESPACE_INFO = PWSANAMESPACE_INFOA
     1232TypeDef LPWSANAMESPACE_INFO = LPWSANAMESPACE_INFOA
     1233#endif
     1234
     1235' Socket function prototypes
     1236
     1237#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1238Declare Function accept Lib "ws2_32" (s As SOCKET, ByRef addr As sockaddr, ByRef addrlen As Long) As SOCKET
     1239#endif
     1240
     1241#ifdef INCL_WINSOCK_API_TYPEDEFS
     1242TypeDef LPFN_ACCEPT = *Function(s As SOCKET, ByRef addr As sockaddr, ByRef addrlen As Long) As SOCKET
     1243#endif
     1244
     1245#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1246Declare Function bind Lib "ws2_32" (s As SOCKET, ByRef name As sockaddr, addrlen As Long) As Long
     1247#endif
     1248
     1249#ifdef INCL_WINSOCK_API_TYPEDEFS
     1250TypeDef LPFN_BIND = *Function(s As SOCKET, ByRef name As sockaddr, addrlen As Long) As Long
     1251#endif
     1252
     1253#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1254Declare Function closesocket Lib "ws2_32" (s As SOCKET) As Long
     1255#endif
     1256
     1257#ifdef INCL_WINSOCK_API_TYPEDEFS
     1258TypeDef LPFN_CLOSESOCKET = *Function(s As SOCKET) As Long
     1259#endif
     1260
     1261#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1262Declare Function connect Lib "ws2_32" (s As SOCKET, ByRef name As sockaddr, namelen As Long) As Long
     1263#endif
     1264
     1265#ifdef INCL_WINSOCK_API_TYPEDEFS
     1266TypeDef LPFN_CONNECT = *Function(s As SOCKET, ByRef name As sockaddr, namelen As Long) As Long
     1267#endif
     1268
     1269#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1270Declare Function ioctlsocket Lib "ws2_32" (s As SOCKET, cmd As Long, ByRef argp As DWord) As Long
     1271#endif
     1272
     1273#ifdef INCL_WINSOCK_API_TYPEDEFS
     1274TypeDef LPFN_IOCTLSOCKET = *Function(s As SOCKET, cmd As Long, ByRef argp As DWord) As Long
     1275#endif
     1276
     1277#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1278Declare Function getpeername Lib "ws2_32" (s As SOCKET, ByRef name As sockaddr, ByRef namelen As Long) As Long
     1279#endif
     1280
     1281#ifdef INCL_WINSOCK_API_TYPEDEFS
     1282TypeDef LPFN_GETPEERNAME = *Function(s As SOCKET, ByRef name As sockaddr, ByRef namelen As Long) As Long
     1283#endif
     1284
     1285#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1286Declare Function getsockname Lib "ws2_32" (s As SOCKET, ByRef name As sockaddr, ByRef namelen As Long) As Long
     1287#endif
     1288
     1289#ifdef INCL_WINSOCK_API_TYPEDEFS
     1290TypeDef LPFN_GETSOCKNAME = *Function(s As SOCKET, ByRef name As sockaddr, ByRef namelen As Long) As Long
     1291#endif
     1292
     1293#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1294Declare Function getsockopt Lib "ws2_32" (s As SOCKET, level As Long, optname As Long, optval As *Byte, ByRef optlen As Long) As Long
     1295#endif
     1296
     1297#ifdef INCL_WINSOCK_API_TYPEDEFS
     1298TypeDef LPFN_GETSOCKOPT = *Function(s As SOCKET, level As Long, optname As Long, optval As *Byte, ByRef optlen As Long) As Long
     1299#endif
     1300
     1301#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1302Declare Function htonl Lib "ws2_32" (hostlong As DWord) As DWord
     1303#endif
     1304
     1305#ifdef INCL_WINSOCK_API_TYPEDEFS
     1306TypeDef LPFN_HTONL = *Function(hostlong As DWord) As DWord
     1307#endif
     1308
     1309#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1310Declare Function htons Lib "ws2_32" (hostshort As Word) As Word
     1311#endif
     1312
     1313#ifdef INCL_WINSOCK_API_TYPEDEFS
     1314TypeDef LPFN_HTONS = *Function(hostshort As Word) As Word
     1315#endif
     1316
     1317#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1318Declare Function inet_addr Lib "ws2_32" (cp As *Byte) As DWord
     1319#endif
     1320
     1321#ifdef INCL_WINSOCK_API_TYPEDEFS
     1322TypeDef LPFN_INET_ADDR = *Function(cp As *Byte) As DWord
     1323#endif
     1324
     1325#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1326Declare Function inet_ntoa Lib "ws2_32" (in As in_addr) As *Byte
     1327#endif
     1328
     1329#ifdef INCL_WINSOCK_API_TYPEDEFS
     1330TypeDef LPFN_INET_NTOA = *Function(in As in_addr) As *Byte
     1331#endif
     1332
     1333#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1334Declare Function listen Lib "ws2_32" (s As SOCKET, backlog As Long) As Long
     1335#endif
     1336
     1337#ifdef INCL_WINSOCK_API_TYPEDEFS
     1338TypeDef LPFN_LISTEN = *Function(s As SOCKET, backlog As Long) As Long
     1339#endif
     1340
     1341#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1342Declare Function ntohl Lib "ws2_32" (netlong As DWord) As DWord
     1343#endif
     1344
     1345#ifdef INCL_WINSOCK_API_TYPEDEFS
     1346TypeDef LPFN_NTOHL = *Function(netlong As DWord) As DWord
     1347#endif
     1348
     1349#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1350Declare Function ntohs Lib "ws2_32" (netshort As Word) As Word
     1351#endif
     1352
     1353#ifdef INCL_WINSOCK_API_TYPEDEFS
     1354TypeDef LPFN_NTOHS = *Function(netshort As Word) As Word
     1355#endif
     1356
     1357#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1358Declare Function recv Lib "ws2_32" (s As SOCKET, buf As *Byte, len As Long, flags As Long) As Long
     1359#endif
     1360
     1361#ifdef INCL_WINSOCK_API_TYPEDEFS
     1362TypeDef LPFN_RECV = *Function(s As SOCKET, buf As *Byte, len As Long, flags As Long) As Long
     1363#endif
     1364
     1365#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1366Declare Function recvfrom Lib "ws2_32" (s As SOCKET, buf As *Byte, len As Long, flags As Long, ByRef from As sockaddr, ByRef fromlen As Long) As Long
     1367#endif
     1368
     1369#ifdef INCL_WINSOCK_API_TYPEDEFS
     1370TypeDef LPFN_RECVFROM = *Function(s As SOCKET, buf As *Byte, len As Long, flags As Long, ByRef from As sockaddr, ByRef fromlen As Long) As Long
     1371#endif
     1372
     1373#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1374Declare Function select Lib "ws2_32" (nfds As Long, ByRef readfds As fd_set, ByRef writefds As fd_set, ByRef exceptfds As fd_set, ByRef timeout As timeval) As Long
     1375#endif
     1376
     1377#ifdef INCL_WINSOCK_API_TYPEDEFS
     1378TypeDef LPFN_SELECT = *Function(nfds As Long, ByRef readfds As fd_set, ByRef writefds As fd_set, ByRef exceptfds As fd_set, ByRef timeout As timeval) As Long
     1379#endif
     1380
     1381#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1382Declare Function send Lib "ws2_32" (s As SOCKET, buf As *Byte, len As Long, flags As Long) As Long
     1383#endif
     1384
     1385#ifdef INCL_WINSOCK_API_TYPEDEFS
     1386TypeDef LPFN_SEND = *Function(s As SOCKET, buf As *Byte, len As Long, flags As Long) As Long
     1387#endif
     1388
     1389#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1390Declare Function sendto Lib "ws2_32" (s As SOCKET, buf As *Byte, len As Long, flags As Long, ByRef to_ As sockaddr, tolen As Long) As Long
     1391#endif
     1392
     1393#ifdef INCL_WINSOCK_API_TYPEDEFS
     1394TypeDef LPFN_SENDTO = *Function(s As SOCKET, buf As *Byte, len As Long, flags As Long, ByRef to_ As sockaddr, tolen As Long) As Long
     1395#endif
     1396
     1397#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1398Declare Function setsockopt Lib "ws2_32" (s As SOCKET, level As Long, optname As Long, optval As *Byte, optlen As Long) As Long
     1399#endif
     1400
     1401#ifdef INCL_WINSOCK_API_TYPEDEFS
     1402TypeDef LPFN_SETSOCKOPT = *Function(s As SOCKET, level As Long, optname As Long, optval As *Byte, optlen As Long) As Long
     1403#endif
     1404
     1405#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1406Declare Function shutdown Lib "ws2_32" (s As SOCKET, how As Long) As Long
     1407#endif
     1408
     1409#ifdef INCL_WINSOCK_API_TYPEDEFS
     1410TypeDef LPFN_SHUTDOWN = *Function(s As SOCKET, how As Long) As Long
     1411#endif
     1412
     1413#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1414Declare Function socket Lib "ws2_32" (af As Long, type_ As Long, protocol As Long) As SOCKET
     1415#endif
     1416
     1417#ifdef INCL_WINSOCK_API_TYPEDEFS
     1418TypeDef LPFN_SOCKET = *Function(af As Long, type_ As Long, protocol As Long) As SOCKET
     1419#endif
     1420
     1421' Database function prototypes
     1422
     1423#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1424Declare Function gethostbyaddr Lib "ws2_32" (addr As PCSTR, len As Long, type_ As Long) As *hostent
     1425#endif
     1426
     1427#ifdef INCL_WINSOCK_API_TYPEDEFS
     1428TypeDef LPFN_GETHOSTBYADDR = *Function(addr As PCSTR, len As Long, type_ As Long) As *hostent
     1429#endif
     1430
     1431#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1432Declare Function gethostbyname Lib "ws2_32" (name As PCSTR) As *hostent
     1433#endif
     1434
     1435#ifdef INCL_WINSOCK_API_TYPEDEFS
     1436TypeDef LPFN_GETHOSTBYNAME = *Function(name As PCSTR) As *hostent
     1437#endif
     1438
     1439#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1440Declare Function gethostname Lib "ws2_32" (name As PCSTR, namelen As Long) As Long
     1441#endif
     1442
     1443#ifdef INCL_WINSOCK_API_TYPEDEFS
     1444TypeDef LPFN_GETHOSTNAME = *Function(name As PCSTR, namelen As Long) As Long
     1445#endif
     1446
     1447#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1448Declare Function getservbyport Lib "ws2_32" (port As Long, proto As PCSTR) As *servent
     1449#endif
     1450
     1451#ifdef INCL_WINSOCK_API_TYPEDEFS
     1452TypeDef LPFN_GETSERVBYPORT = *Function(port As Long, proto As PCSTR) As *servent
     1453#endif
     1454
     1455#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1456Declare Function getservbyname Lib "ws2_32" (name As PCSTR, proto As PCSTR) As *servent
     1457#endif
     1458
     1459#ifdef INCL_WINSOCK_API_TYPEDEFS
     1460TypeDef LPFN_GETSERVBYNAME = *Function(name As PCSTR, proto As PCSTR) As *servent
     1461#endif
     1462
     1463#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1464Declare Function getprotobynumber Lib "ws2_32" (number As Long) As *protoent
     1465#endif
     1466
     1467#ifdef INCL_WINSOCK_API_TYPEDEFS
     1468TypeDef LPFN_GETPROTOBYNUMBER = *Function(number As Long) As *protoent
     1469#endif
     1470
     1471#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1472Declare Function getprotobyname Lib "ws2_32" (name As PCSTR) As *protoent
     1473#endif
     1474
     1475#ifdef INCL_WINSOCK_API_TYPEDEFS
     1476TypeDef LPFN_GETPROTOBYNAME = (name As PCSTR) As *protoent
     1477#endif
     1478
     1479' Microsoft Windows Extension function prototypes
     1480
     1481#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1482Declare Function WSAStartup Lib "ws2_32" (wVersionRequested As Word, ByRef WSAData As WSADATA) As Long
     1483#endif
     1484
     1485#ifdef INCL_WINSOCK_API_TYPEDEFS
     1486TypeDef LPFN_WSASTARTUP = *Function(wVersionRequested As Word, ByRef WSAData As WSADATA) As Long
     1487#endif
     1488
     1489#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1490Declare Function WSACleanup Lib "ws2_32" () As Long
     1491#endif
     1492
     1493#ifdef INCL_WINSOCK_API_TYPEDEFS
     1494TypeDef LPFN_WSACLEANUP = *Function() As Long
     1495#endif
     1496
     1497#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1498Declare Sub WSASetLastError Lib "ws2_32" (iError As Long)
     1499#endif
     1500
     1501#ifdef INCL_WINSOCK_API_TYPEDEFS
     1502TypeDef LPFN_WSASETLASTERROR = *Sub(iError As Long)
     1503#endif
     1504
     1505#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1506Declare Function WSAGetLastError Lib "ws2_32" () As Long
     1507#endif
     1508
     1509#ifdef INCL_WINSOCK_API_TYPEDEFS
     1510TypeDef LPFN_WSAGETLASTERROR = *Function() As Long
     1511#endif
     1512
     1513#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1514Declare Function WSAIsBlocking Lib "ws2_32" () As BOOL
     1515#endif
     1516
     1517#ifdef INCL_WINSOCK_API_TYPEDEFS
     1518TypeDef LPFN_WSAISBLOCKING = *Function() As BOOL
     1519#endif
     1520
     1521#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1522Declare Function WSAUnhookBlockingHook Lib "ws2_32" () As Long
     1523#endif
     1524
     1525#ifdef INCL_WINSOCK_API_TYPEDEFS
     1526TypeDef LPFN_WSAUNHOOKBLOCKINGHOOK = *Function() As Long
     1527#endif
     1528
     1529#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1530Declare Function WSASetBlockingHook Lib "ws2_32" (lpBlockFunc As FARPROC) As FARPROC
     1531
     1532#endif
     1533
     1534#ifdef INCL_WINSOCK_API_TYPEDEFS
     1535TypeDef LPFN_WSASETBLOCKINGHOOK = *Function(lpBlockFunc As FARPROC) As FARPROC
     1536#endif
     1537
     1538#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1539Declare Function WSACancelBlockingCall Lib "ws2_32" () As Long
     1540#endif
     1541
     1542#ifdef INCL_WINSOCK_API_TYPEDEFS
     1543TypeDef LPFN_WSACANCELBLOCKINGCALL = *Function() As Long
     1544#endif
     1545
     1546#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1547Declare Function WSAAsyncGetServByName Lib "ws2_32" (hwnd As HWND, msg As DWord, name As PCSTR, proto As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1548#endif
     1549
     1550#ifdef INCL_WINSOCK_API_TYPEDEFS
     1551TypeDef LPFN_WSAASYNCGETSERVBYNAME = *Function(hwnd As HWND, msg As DWord, name As PCSTR, proto As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1552#endif
     1553
     1554#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1555Declare Function WSAAsyncGetServByPort Lib "ws2_32" (hwnd As HWND, msg As DWord, port As Long, proto As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1556#endif
     1557
     1558#ifdef INCL_WINSOCK_API_TYPEDEFS
     1559TypeDef LPFN_WSAASYNCGETSERVBYPORT = *Function(hwnd As HWND, msg As DWord, port As Long, proto As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1560#endif
     1561
     1562#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1563Declare Function WSAAsyncGetProtoByName Lib "ws2_32" (hwnd As HWND, msg As DWord, name As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1564#endif
     1565
     1566#ifdef INCL_WINSOCK_API_TYPEDEFS
     1567TypeDef LPFN_WSAASYNCGETPROTOBYNAME = *Function(hwnd As HWND, msg As DWord, name As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1568#endif
     1569
     1570#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1571Declare Function WSAAsyncGetProtoByNumber Lib "ws2_32" (hwnd As HWND, msg As DWord, number As Long, buf As *Byte, buflen As Long) As HANDLE
     1572#endif
     1573
     1574#ifdef INCL_WINSOCK_API_TYPEDEFS
     1575TypeDef LPFN_WSAASYNCGETPROTOBYNUMBER = *Function(hwnd As HWND, msg As DWord, number As Long, buf As *Byte, buflen As Long) As HANDLE
     1576#endif
     1577
     1578#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1579Declare Function WSAAsyncGetHostByName Lib "ws2_32" (hwnd As HWND, msg As DWord, name As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1580#endif
     1581
     1582#ifdef INCL_WINSOCK_API_TYPEDEFS
     1583TypeDef LPFN_WSAASYNCGETHOSTBYNAME = *Function(hwnd As HWND, msg As DWord, name As PCSTR, buf As *Byte, buflen As Long) As HANDLE
     1584#endif
     1585
     1586#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1587Declare Function WSAAsyncGetHostByAddr Lib "ws2_32" (hwnd As HWND, msg As DWord, addr As PCSTR, len As Long, type_ As Long, buf As *Byte, buflen As Long) As HANDLE
     1588#endif
     1589
     1590#ifdef INCL_WINSOCK_API_TYPEDEFS
     1591TypeDef LPFN_WSAASYNCGETHOSTBYADDR = *Function(hwnd As HWND, msg As DWord, addr As PCSTR, len As Long, type_ As Long, buf As *Byte, buflen As Long) As HANDLE
     1592#endif
     1593
     1594#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1595Declare Function WSACancelAsyncRequest Lib "ws2_32" (hAsyncTaskHandle As HANDLE) As Long
     1596#endif
     1597
     1598#ifdef INCL_WINSOCK_API_TYPEDEFS
     1599TypeDef LPFN_WSACANCELASYNCREQUEST = *Function(hAsyncTaskHandle As HANDLE) As Long
     1600#endif
     1601
     1602#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1603Declare Function WSAAsyncSelect Lib "ws2_32" (s As SOCKET, hwnd As HWND, msg As DWord, Event As Long) As Long
     1604#endif
     1605
     1606#ifdef INCL_WINSOCK_API_TYPEDEFS
     1607TypeDef LPFN_WSAASYNCSELECT = *Function(s As SOCKET, hwnd As HWND, msg As DWord, Event As Long) As Long
     1608#endif
     1609
     1610/* WinSock 2 API new function prototypes */
     1611
     1612#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1613Declare Function WSAAccept Lib "ws2_32" (s As SOCKET, ByRef addr As sockaddr, ByRef addrlen As Long, lpfnCondition As LPCONDITIONPROC, CallbackData As ULONG_PTR) As SOCKET
     1614#endif
     1615
     1616#ifdef INCL_WINSOCK_API_TYPEDEFS
     1617TypeDef LPFN_WSAACCEPT = *Function(s As SOCKET, ByRef addr As sockaddr, ByRef addrlen As Long, lpfnCondition As LPCONDITIONPROC, CallbackData As ULONG_PTR) As SOCKET
     1618#endif
     1619
     1620#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1621Declare Function WSACloseEvent Lib "ws2_32" (hEvent As WSAEVENT) As BOOL
     1622#endif
     1623
     1624#ifdef INCL_WINSOCK_API_TYPEDEFS
     1625TypeDef LPFN_WSACLOSEEVENT = *Function(hEvent As WSAEVENT) As BOOL
     1626#endif
     1627
     1628#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1629Declare Function WSAConnect Lib "ws2_32" (s As SOCKET, ByRef name As sockaddr, namelen As Long, ByRef CallerData As WSABUF, ByRef CalleeData As WSABUF, ByRef SQOS As QOS, ByRef GQOS As QOS) As Long
     1630#endif
     1631
     1632#ifdef INCL_WINSOCK_API_TYPEDEFS
     1633TypeDef LPFN_WSACONNECT = *Functions As SOCKET, ByRef name As sockaddr, namelen As Long, ByRef CallerData As WSABUF, ByRef CalleeData As WSABUF, ByRef SQOS As QOS, ByRef GQOS As QOS) As Long
     1634#endif
     1635
     1636#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1637Declare Function WSACreateEvent Lib "ws2_32" () As WSAEVENT
     1638#endif
     1639
     1640#ifdef INCL_WINSOCK_API_TYPEDEFS
     1641TypeDef LPFN_WSACREATEEVENT = *Function() As WSAEVENT
     1642#endif
     1643
     1644#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1645Declare Function WSADuplicateSocketA Lib "ws2_32" (s As SOCKET, ProcessId As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOA) As Long
     1646Declare Function WSADuplicateSocketW Lib "ws2_32" (s As SOCKET, ProcessId As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOW) As Long
     1647#ifdef UNICODE
     1648Declare Function WSADuplicateSocket Lib "ws2_32" Alias "WSADuplicateSocketW" (s As SOCKET, ProcessId As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFO) As Long
     1649#else
     1650Declare Function WSADuplicateSocket Lib "ws2_32" Alias "WSADuplicateSocketA" (s As SOCKET, ProcessId As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFO) As Long
     1651#endif
     1652#endif
     1653
     1654#ifdef INCL_WINSOCK_API_TYPEDEFS
     1655TypeDef LPFN_WSADUPLICATESOCKETA = *Function(s As SOCKET, ProcessId As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOA) As Long
     1656TypeDef LPFN_WSADUPLICATESOCKETW = *Function(s As SOCKET, ProcessId As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOW) As Long
     1657#ifdef UNICODE
     1658TypeDef LPFN_WSADUPLICATESOCKET = LPFN_WSADUPLICATESOCKETW
     1659#else
     1660TypeDef LPFN_WSADUPLICATESOCKET = LPFN_WSADUPLICATESOCKETA
     1661#endif
     1662#endif
     1663
     1664#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1665Declare Function WSAEnumNetworkEvents Lib "ws2_32" (s As SOCKET, hEventObject As WSAEVENT, ByRef NetworkEvents As WSANETWORKEVENTS) As Long
     1666#endif
     1667
     1668#ifdef INCL_WINSOCK_API_TYPEDEFS
     1669TypeDef LPFN_WSAENUMNETWORKEVENTS = *Function(s As SOCKET, hEventObject As WSAEVENT, ByRef NetworkEvents As WSANETWORKEVENTS) As Long
     1670#endif
     1671
     1672#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1673Declare Function WSAEnumProtocolsA Lib "ws2_32" (Protocols As *Long, ByRef ProtocolBuffer As WSAPROTOCOL_INFOA, ByRef BufferLength As DWord) As Long
     1674Declare Function WSAEnumProtocolsW Lib "ws2_32" (Protocols As *Long, ByRef ProtocolBuffer As WSAPROTOCOL_INFOW, ByRef BufferLength As DWord) As Long
     1675#ifdef UNICODE
     1676Declare Function WSAEnumProtocols Lib "ws2_32" Alias "WSAEnumProtocolsW" (Protocols As *Long, ByRef ProtocolBuffer As WSAPROTOCOL_INFO, ByRef BufferLength As DWord) As Long
     1677#else
     1678Declare Function WSAEnumProtocols Lib "ws2_32" Alias "WSAEnumProtocolsA" (Protocols As *Long, ByRef ProtocolBuffer As WSAPROTOCOL_INFO, ByRef BufferLength As DWord) As Long
     1679#endif
     1680#endif
     1681
     1682#ifdef INCL_WINSOCK_API_TYPEDEFS
     1683TypeDef LPFN_WSAENUMPROTOCOLSA = *Function(Protocols As *Long, ByRef ProtocolBuffer As WSAPROTOCOL_INFOA, ByRef BufferLength As DWord) As Long
     1684TypeDef LPFN_WSAENUMPROTOCOLSW = *Function(Protocols As *Long, ByRef ProtocolBuffer As WSAPROTOCOL_INFOW, ByRef BufferLength As DWord) As Long
     1685#ifdef UNICODE
     1686TypeDef LPFN_WSAENUMPROTOCOLS = LPFN_WSAENUMPROTOCOLSW
     1687#else
     1688TypeDef LPFN_WSAENUMPROTOCOLS = LPFN_WSAENUMPROTOCOLSA
     1689#endif
     1690#endif
     1691
     1692#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1693Declare Function WSAEventSelect Lib "ws2_32" (s As SOCKET, hEventObject As WSAEVENT, NetworkEvents As Long) As Long
     1694#endif
     1695
     1696#ifdef INCL_WINSOCK_API_TYPEDEFS
     1697TypeDef LPFN_WSAEVENTSELECT = *Function(s As SOCKET, hEventObject As WSAEVENT, NetworkEvents As Long) As Long
     1698#endif
     1699
     1700#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1701Declare Function WSAGetOverlappedResult Lib "ws2_32" (s As SOCKET, ByRef Overlapped As WSAOVERLAPPED, ByRef cbTransfer As DWord, Wait As BOOL, ByRef Flags As DWord) As BOOL
     1702#endif
     1703
     1704#ifdef INCL_WINSOCK_API_TYPEDEFS
     1705TypeDef LPFN_WSAGETOVERLAPPEDRESULT = *Function(s As SOCKET, ByRef Overlapped As WSAOVERLAPPED, ByRef cbTransfer As DWord, Wait As BOOL, ByRef Flags As DWord) As BOOL
     1706#endif
     1707
     1708#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1709Declare Function WSAGetQOSByName Lib "ws2_32" (s As SOCKET, ByRef QOSName As WSABUF, ByRef qos As QOS) As BOOL
     1710#endif
     1711
     1712#ifdef INCL_WINSOCK_API_TYPEDEFS
     1713TypeDef LPFN_WSAGETQOSBYNAME = *Function(s As SOCKET, ByRef QOSName As WSABUF, ByRef qos As QOS) As BOOL
     1714#endif
     1715
     1716#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1717Declare Function WSAHtonl Lib "ws2_32" (s As SOCKET, hostlong As DWord, ByRef netlong As DWord) As Long
     1718#endif
     1719
     1720#ifdef INCL_WINSOCK_API_TYPEDEFS
     1721TypeDef LPFN_WSAHTONL = *Function(s As SOCKET, hostlong As DWord, ByRef netlong As DWord) As Long
     1722#endif
     1723
     1724#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1725Declare Function WSAHtons Lib "ws2_32" (s As SOCKET, hostshort As Word, ByRef netshort As Word) As Long
     1726#endif
     1727
     1728#ifdef INCL_WINSOCK_API_TYPEDEFS
     1729TypeDef LPFN_WSAHTONS = *Function(s As SOCKET, hostshort As Word, ByRef netshort As Word) As Long
     1730#endif
     1731
     1732#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1733Declare Function WSAIoctl Lib "ws2_32" (s As SOCKET, IoControlCode As DWord, pvInBuffer As VoidPtr, cbInBuffer As DWord, pvOutBuffer As VoidPtr, cbOutBuffer As DWord,
     1734    ByRef cbBytesReturned As DWord, ByRef Overlapped As WSAOVERLAPPED, pCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1735#endif
     1736
     1737#ifdef INCL_WINSOCK_API_TYPEDEFS
     1738TypeDef LPFN_WSAIOCTL = *Function(s As SOCKET, IoControlCode As DWord, pvInBuffer As VoidPtr, cbInBuffer As DWord, pvOutBuffer As VoidPtr, cbOutBuffer As DWord,
     1739    ByRef cbBytesReturned As DWord, ByRef Overlapped As WSAOVERLAPPED, pCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1740#endif
     1741
     1742#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1743Declare Function WSAJoinLeaf Lib "ws2_32" (s As SOCKET, ByRef name As sockaddr, namelen As Long, ByRef CallerData As WSABUF, ByRef CalleeData As WSABUF,
     1744    ByRef SQOS As QOS, ByRef GQOS AS QOS, Flags As DWord) As SOCKET
     1745#endif
     1746
     1747#ifdef INCL_WINSOCK_API_TYPEDEFS
     1748TypeDef LPFN_WSAJOINLEAF = *Function(s As SOCKET, ByRef name As sockaddr, namelen As Long, ByRef CallerData As WSABUF, ByRef CalleeData As WSABUF,
     1749    ByRef SQOS As QOS, ByRef GQOS AS QOS, Flags As DWord) As SOCKET
     1750#endif
     1751
     1752#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1753Declare Function WSANtohl Lib "ws2_32" (s As SOCKET, netlong As DWord, ByRef hostlong As DWord) As Long
     1754#endif
     1755
     1756#ifdef INCL_WINSOCK_API_TYPEDEFS
     1757TypeDef LPFN_WSANTOHL = *Function(s As SOCKET, netlong As DWord, ByRef hostlong As DWord) As Long
     1758#endif
     1759
     1760#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1761Declare Function WSANtohs Lib "ws2_32" (s As SOCKET, netshort As Word, ByRef hostshort As Word) As Long
     1762#endif
     1763
     1764#ifdef INCL_WINSOCK_API_TYPEDEFS
     1765TypeDef LPFN_WSANTOHS = *Function(s As SOCKET, netshort As Word, ByRef hostshort As Word) As Long
     1766#endif
     1767
     1768#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1769Declare Function WSARecv Lib "ws2_32" (s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesRecvd As DWord, ByRef Flags As DWord,
     1770    ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1771#endif
     1772
     1773#ifdef INCL_WINSOCK_API_TYPEDEFS
     1774TypeDef LPFN_WSARECV = *Function(s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesRecvd As DWord, ByRef Flags As DWord,
     1775    ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1776#endif
     1777
     1778#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1779Declare Function WSARecvDisconnect Lib "ws2_32" (s As SOCKET, ByRef InboundDisconnectData As WSABUF) As Long
     1780#endif
     1781
     1782#ifdef INCL_WINSOCK_API_TYPEDEFS
     1783TypeDef LPFN_WSARECVDISCONNECT = *Function(s As SOCKET, ByRef InboundDisconnectData As WSABUF) As Long
     1784#endif
     1785
     1786#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1787Declare Function WSARecvFrom Lib "ws2_32" (s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesRecvd As DWord, ByRef Flags As DWord,
     1788    ByRef From As sockaddr, ByRef Fromlen As Long, ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1789#endif
     1790
     1791#ifdef INCL_WINSOCK_API_TYPEDEFS
     1792TypeDef LPFN_WSARECVFROM = *Function(s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesRecvd As DWord, ByRef Flags As DWord,
     1793    ByRef From As sockaddr, ByRef Fromlen As Long, ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1794#endif
     1795
     1796#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1797Declare Function WSAResetEvent Lib "ws2_32" (hEvent As WSAEVENT) As BOOL
     1798#endif
     1799
     1800#ifdef INCL_WINSOCK_API_TYPEDEFS
     1801TypeDef LPFN_WSARESETEVENT = *Function(hEvent As WSAEVENT) As BOOL
     1802#endif
     1803
     1804#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1805Declare Function WSASend Lib "ws2_32" (s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesSent As DWord, ByRef Flags As DWord,
     1806    ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1807#endif
     1808
     1809#ifdef INCL_WINSOCK_API_TYPEDEFS
     1810TypeDef LPFN_WSASEND = *Function(s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesSent As DWord, ByRef Flags As DWord,
     1811    ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1812#endif
     1813
     1814#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1815Declare Function WSASendDisconnect Lib "ws2_32" (s As SOCKET, ByRef OutboundDisconnectData As WSABUF) As Long
     1816#endif
     1817
     1818#ifdef INCL_WINSOCK_API_TYPEDEFS
     1819TypeDef LPFN_WSASENDDISCONNECT = *Function(s As SOCKET, ByRef OutboundDisconnectData As WSABUF) As Long
     1820#endif
     1821
     1822#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1823Declare Function WSASendTo Lib "ws2_32" (s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesSent As DWord, ByRef Flags As DWord,
     1824    ByRef To_ As sockaddr, ToLen As Long, ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1825#endif
     1826
     1827#ifdef INCL_WINSOCK_API_TYPEDEFS
     1828TypeDef LPFN_WSASENDTO = *Function(s As SOCKET, ByRef Buffers As WSABUF, BufferCount As DWord, ByRef NumberOfBytesSent As DWord, ByRef Flags As DWord,
     1829    ByRef To_ As sockaddr, ToLen As Long, ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     1830#endif
     1831
     1832#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1833Declare Function WSASetEvent Lib "ws2_32" (hEvent As WSAEVENT) As BOOL
     1834#endif
     1835
     1836#ifdef INCL_WINSOCK_API_TYPEDEFS
     1837TypeDef LPFN_WSASETEVENT = *Function(hEvent As WSAEVENT) As BOOL
     1838#endif
     1839
     1840#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1841Declare Function WSASocketA Lib "ws2_32" (af As Long, type_ As Long, protocol As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOA, g As GROUP, Flags As DWord) As SOCKET
     1842Declare Function WSASocketW Lib "ws2_32" (af As Long, type_ As Long, protocol As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOW, g As GROUP, Flags As DWord) As SOCKET
     1843#ifdef UNICODE
     1844Declare Function WSASocket Lib "ws2_32" Alias "WSASocketW" (af As Long, type_ As Long, protocol As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFO, g As GROUP, Flags As DWord) As SOCKET
     1845#else
     1846Declare Function WSASocket Lib "ws2_32" Alias "WSASocketA" (af As Long, type_ As Long, protocol As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFO, g As GROUP, Flags As DWord) As SOCKET
     1847#endif
     1848#endif
     1849
     1850#ifdef INCL_WINSOCK_API_TYPEDEFS
     1851TypeDef LPFN_WSASOCKETA = *Function(af As Long, type_ As Long, protocol As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOA, g As GROUP, Flags As DWord) As SOCKET
     1852TypeDef LPFN_WSASOCKETW = *Function(af As Long, type_ As Long, protocol As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOW, g As GROUP, Flags As DWord) As SOCKET
     1853#ifdef UNICODE
     1854TypeDef LPFN_WSASOCKET = LPFN_WSASOCKETW
     1855#else
     1856TypeDef LPFN_WSASOCKET = LPFN_WSASOCKETA
     1857#endif
     1858#endif
     1859
     1860#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1861Declare Function WSAWaitForMultipleEvents Lib "ws2_32" (cEvents As DWord, phEvents As *WSAEVENT, WaitAll As BOOL, Timeout As DWord, Alertable As BOOL) As DWord
     1862#endif
     1863
     1864#ifdef INCL_WINSOCK_API_TYPEDEFS
     1865TypeDef LPFN_WSAWAITFORMULTIPLEEVENTS = *Function(cEvents As DWord, phEvents As *WSAEVENT, WaitAll As BOOL, Timeout As DWord, Alertable As BOOL) As DWord
     1866#endif
     1867
     1868#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1869Declare Function WSAAddressToStringA Lib "ws2_32" (ByRef saAddress As SOCKADDR, AddressLength As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOA,
     1870    AddressString As PSTR, ByRef dwAddressStringLength As DWord) As Long
     1871Declare Function WSAAddressToStringW Lib "ws2_32" (ByRef saAddress As SOCKADDR, AddressLength As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOA,
     1872    AddressString As PWSTR, ByRef dwAddressStringLength As DWord) As Long
     1873#ifdef UNICODE
     1874Declare Function WSAAddressToString Lib "ws2_32" Alias "WSAAddressToStringW" (ByRef saAddress As SOCKADDR, AddressLength As DWord,
     1875    ByRef ProtocolInfo As WSAPROTOCOL_INFO, AddressString As PSTR, ByRef dwAddressStringLength As DWord) As Long
     1876#else
     1877Declare Function WSAAddressToString Lib "ws2_32" Alias "WSAAddressToStringA" (ByRef saAddress As SOCKADDR, AddressLength As DWord,
     1878    ByRef ProtocolInfo As WSAPROTOCOL_INFO, AddressString As PSTR, ByRef dwAddressStringLength As DWord) As Long
     1879#endif
     1880#endif
     1881
     1882#ifdef INCL_WINSOCK_API_TYPEDEFS
     1883TypeDef LPFN_WSAADDRESSTOSTRINGA = *Function(ByRef saAddress As SOCKADDR, AddressLength As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOA,
     1884    AddressString As PSTR, ByRef dwAddressStringLength As DWord) As Long
     1885TypeDef LPFN_WSAADDRESSTOSTRINGW = *Function(ByRef saAddress As SOCKADDR, AddressLength As DWord, ByRef ProtocolInfo As WSAPROTOCOL_INFOA,
     1886    AddressString As PWSTR, ByRef dwAddressStringLength As DWord) As Long
     1887#ifdef UNICODE
     1888TypeDef LPFN_WSAADDRESSTOSTRING = LPFN_WSAADDRESSTOSTRINGW
     1889#else
     1890TypeDef LPFN_WSAADDRESSTOSTRING = LPFN_WSAADDRESSTOSTRINGA
     1891#endif
     1892#endif
     1893
     1894#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1895Declare Function WSAStringToAddressA Lib "ws2_32" (AddressString As PSTR, AddressFamily As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOA,
     1896    ByRef Address As SOCKADDR, ByRef AddressLength As Long) As Long
     1897Declare Function WSAStringToAddressW Lib "ws2_32" (AddressString As PWSTR, AddressFamily As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOW,
     1898    ByRef Address As SOCKADDR, ByRef AddressLength As Long) As Long
     1899#ifdef UNICODE
     1900Declare Function WSAStringToAddress Lib "ws2_32" Alias "WSAStringToAddressW" (AddressString As PSTR, AddressFamily As Long,
     1901    ByRef ProtocolInfo As WSAPROTOCOL_INFO, ByRef Address As SOCKADDR, ByRef AddressLength As Long) As Long
     1902#else
     1903Declare Function WSAStringToAddress Lib "ws2_32" Alias "WSAStringToAddressA" (AddressString As PSTR, AddressFamily As Long,
     1904    ByRef ProtocolInfo As WSAPROTOCOL_INFO, ByRef Address As SOCKADDR, ByRef AddressLength As Long) As Long
     1905#endif
     1906#endif
     1907
     1908#ifdef INCL_WINSOCK_API_TYPEDEFS
     1909TypeDef LPFN_WSASTRINGTOADDRESSA = *Function(AddressString As PSTR, AddressFamily As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOA,
     1910    ByRef Address As SOCKADDR, ByRef AddressLength As Long) As Long
     1911TypeDef LPFN_WSASTRINGTOADDRESSW = *Function(AddressString As PWSTR, AddressFamily As Long, ByRef ProtocolInfo As WSAPROTOCOL_INFOW,
     1912    ByRef Address As SOCKADDR, ByRef AddressLength As Long) As Long
     1913#ifdef UNICODE
     1914TypeDef LPFN_WSASTRINGTOADDRESS = LPFN_WSASTRINGTOADDRESSW
     1915#else
     1916TypeDef LPFN_WSASTRINGTOADDRESS = LPFN_WSASTRINGTOADDRESSA
     1917#endif
     1918#endif
     1919
     1920' Registration and Name Resolution API functions
     1921#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1922Declare Function WSALookupServiceBeginA Lib "ws2_32" (ByRef qsRestrictions As WSAQUERYSETA, ControlFlags As DWord, ByRef hLookup As HANDLE) As Long
     1923Declare Function WSALookupServiceBeginW Lib "ws2_32" (ByRef qsRestrictions As WSAQUERYSETW, ControlFlags As DWord, ByRef hLookup As HANDLE) As Long
     1924#ifdef UNICODE
     1925Declare Function WSALookupServiceBegin Lib "ws2_32" Alias "WSALookupServiceBeginW" (ByRef qsRestrictions As WSAQUERYSET, ControlFlags As DWord, ByRef hLookup As HANDLE) As Long
     1926#else
     1927Declare Function WSALookupServiceBegin Lib "ws2_32" Alias "WSALookupServiceBeginA" (ByRef qsRestrictions As WSAQUERYSET, ControlFlags As DWord, ByRef hLookup As HANDLE) As Long
     1928#endif
     1929#endif
     1930
     1931#ifdef INCL_WINSOCK_API_TYPEDEFS
     1932TypeDef LPFN_WSALOOKUPSERVICEBEGINA = *Function(ByRef qsRestrictions As WSAQUERYSETA, ControlFlags As DWord, ByRef hLookup As HANDLE) As Long
     1933TypeDef LPFN_WSALOOKUPSERVICEBEGINW = *Function(ByRef qsRestrictions As WSAQUERYSETW, ControlFlags As DWord, ByRef hLookup As HANDLE) As Long
     1934#ifdef UNICODE
     1935TypeDef LPFN_WSALOOKUPSERVICEBEGIN = LPFN_WSALOOKUPSERVICEBEGINW
     1936#else
     1937TypeDef LPFN_WSALOOKUPSERVICEBEGIN = LPFN_WSALOOKUPSERVICEBEGINA
     1938#endif
     1939#endif
     1940
     1941#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1942Declare Function WSALookupServiceNextA Lib "ws2_32" (hLookup As HANDLE, ControlFlags As DWord, ByRef BufferLength As DWord, ByRef qsResults As WSAQUERYSETA) As Long
     1943Declare Function WSALookupServiceNextW Lib "ws2_32" (hLookup As HANDLE, ControlFlags As DWord, ByRef BufferLength As DWord, ByRef qsResults As WSAQUERYSETW) As Long
     1944#ifdef UNICODE
     1945Declare Function WSALookupServiceNext Lib "ws2_32" Alias "WSALookupServiceNextW" (hLookup As HANDLE, ControlFlags As DWord, ByRef BufferLength As DWord, ByRef qsResults As WSAQUERYSET) As Long
     1946#else
     1947Declare Function WSALookupServiceNext Lib "ws2_32" Alias "WSALookupServiceNextA" (hLookup As HANDLE, ControlFlags As DWord, ByRef BufferLength As DWord, ByRef qsResults As WSAQUERYSET) As Long
     1948#endif
     1949#endif
     1950
     1951#ifdef INCL_WINSOCK_API_TYPEDEFS
     1952TypeDef LPFN_WSALOOKUPSERVICENEXTA = *FunctionhLookup As HANDLE, ControlFlags As DWord, ByRef BufferLength As DWord, ByRef qsResults As WSAQUERYSETA) As Long
     1953TypeDef LPFN_WSALOOKUPSERVICENEXTW = *FunctionhLookup As HANDLE, ControlFlags As DWord, ByRef BufferLength As DWord, ByRef qsResults As WSAQUERYSETW) As Long
     1954#ifdef UNICODE
     1955TypeDef LPFN_WSALOOKUPSERVICENEXT = LPFN_WSALOOKUPSERVICENEXTW
     1956#else
     1957TypeDef LPFN_WSALOOKUPSERVICENEXT = LPFN_WSALOOKUPSERVICENEXTA
     1958#endif
     1959#endif
     1960
     1961#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1962Declare Function WSANSPIoctl Lib "ws2_32" (hLookup As HANDLE, ControlCode As DWord, pvInBuffer As VoidPtr, cbInBuffer As DWord,
     1963    pvOutBuffer As VoidPtr, cbOutBuffer As DWord, ByRef cbBytesReturned As DWord, ByRef Completion As WSACOMPLETION) As Long
     1964#endif
     1965
     1966#ifdef INCL_WINSOCK_API_TYPEDEFS
     1967TypeDef LPFN_WSANSPIOCTL = *Function(hLookup As HANDLE, ControlCode As DWord, pvInBuffer As VoidPtr, cbInBuffer As DWord,
     1968    pvOutBuffer As VoidPtr, cbOutBuffer As DWord, ByRef cbBytesReturned As DWord, ByRef Completion As WSACOMPLETION) As Long
     1969#endif
     1970
     1971#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1972Declare Function WSALookupServiceEnd Lib "ws2_32" (hLookup As HANDLE) As Long
     1973#endif
     1974
     1975#ifdef INCL_WINSOCK_API_TYPEDEFS
     1976TypeDef LPFN_WSALOOKUPSERVICEEND = *Function(hLookup As HANDLE) As Long
     1977#endif
     1978
     1979#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     1980Declare Function WSAInstallServiceClassA Lib "ws2_32" (ByRef ServiceClassInfo As WSASERVICECLASSINFOA) As Long
     1981Declare Function WSAInstallServiceClassW Lib "ws2_32" (ByRef ServiceClassInfo As WSASERVICECLASSINFOW) As Long
     1982#ifdef UNICODE
     1983Declare Function WSAInstallServiceClass Lib "ws2_32" Alias "WSAInstallServiceClassW" (ByRef ServiceClassInfo As WSASERVICECLASSINFO) As Long
     1984#else
     1985Declare Function WSAInstallServiceClass Lib "ws2_32" Alias "WSAInstallServiceClassA" (ByRef ServiceClassInfo As WSASERVICECLASSINFO) As Long
     1986#endif
     1987#endif
     1988
     1989#ifdef INCL_WINSOCK_API_TYPEDEFS
     1990TypeDef LPFN_WSAINSTALLSERVICECLASSA = *Function(ByRef ServiceClassInfo As WSASERVICECLASSINFOA) As Long
     1991TypeDef LPFN_WSAINSTALLSERVICECLASSW = *Function(ByRef ServiceClassInfo As WSASERVICECLASSINFOW) As Long
     1992#ifdef UNICODE
     1993TypeDef LPFN_WSAINSTALLSERVICECLASS = LPFN_WSAINSTALLSERVICECLASSW
     1994#else
     1995TypeDef LPFN_WSAINSTALLSERVICECLASS = LPFN_WSAINSTALLSERVICECLASSA
     1996#endif
     1997#endif
     1998
     1999#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     2000Declare Function WSARemoveServiceClass Lib "ws2_32" (ByRef ServiceClassId As GUID) As Long
     2001#endif
     2002
     2003#ifdef INCL_WINSOCK_API_TYPEDEFS
     2004TypeDef LPFN_WSAREMOVESERVICECLASS = *Function(ByRef ServiceClassId As GUID) As Long
     2005#endif
     2006
     2007#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     2008Declare Function WSAGetServiceClassInfoA Lib "ws2_32" (ByRef ProviderId As GUID, ByRef ServiceClassId As GUID, ByRef BufSize As DWord, ByRef ServiceClassInfo As WSASERVICECLASSINFOA) As Long
     2009Declare Function WSAGetServiceClassInfoW Lib "ws2_32" (ByRef ProviderId As GUID, ByRef ServiceClassId As GUID, ByRef BufSize As DWord, ByRef ServiceClassInfo As WSASERVICECLASSINFOW) As Long
     2010#ifdef UNICODE
     2011Declare Function WSAGetServiceClassInfo Lib "ws2_32" Alias "WSAGetServiceClassInfoW" (ByRef ProviderId As GUID, ByRef ServiceClassId As GUID, ByRef BufSize As DWord, ByRef ServiceClassInfo As WSASERVICECLASSINFO) As Long
     2012#else
     2013Declare Function WSAGetServiceClassInfo Lib "ws2_32" Alias "WSAGetServiceClassInfoA" (ByRef ProviderId As GUID, ByRef ServiceClassId As GUID, ByRef BufSize As DWord, ByRef ServiceClassInfo As WSASERVICECLASSINFO) As Long
     2014#endif
     2015#endif
     2016
     2017#ifdef INCL_WINSOCK_API_TYPEDEFS
     2018TypeDef LPFN_WSAGETSERVICECLASSINFOA = *Function(ByRef ProviderId As GUID, ByRef ServiceClassId As GUID, ByRef BufSize As DWord, ByRef ServiceClassInfo As WSASERVICECLASSINFOA) As Long
     2019TypeDef LPFN_WSAGETSERVICECLASSINFOW = *Function(ByRef ProviderId As GUID, ByRef ServiceClassId As GUID, ByRef BufSize As DWord, ByRef ServiceClassInfo As WSASERVICECLASSINFOW) As Long
     2020#ifdef UNICODE
     2021TypeDef LPFN_WSAGETSERVICECLASSINFO = LPFN_WSAGETSERVICECLASSINFOW
     2022#else
     2023TypeDef LPFN_WSAGETSERVICECLASSINFO = LPFN_WSAGETSERVICECLASSINFOA
     2024#endif
     2025#endif
     2026
     2027#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     2028Declare Function WSAEnumNameSpaceProvidersA Lib "ws2_32" (ByRef BufferLength As DWord, ByRef nspBuffer As WSANAMESPACE_INFOA) As Long
     2029Declare Function WSAEnumNameSpaceProvidersW Lib "ws2_32" (ByRef BufferLength As DWord, ByRef nspBuffer As WSANAMESPACE_INFOW) As Long
     2030#ifdef UNICODE
     2031Declare Function WSAEnumNameSpaceProviders Lib "ws2_32" Alias "WSAEnumNameSpaceProvidersW" (ByRef BufferLength As DWord, ByRef nspBuffer As WSANAMESPACE_INFO) As Long
     2032#else
     2033Declare Function WSAEnumNameSpaceProviders Lib "ws2_32" Alias "WSAEnumNameSpaceProvidersA" (ByRef BufferLength As DWord, ByRef nspBuffer As WSANAMESPACE_INFO) As Long
     2034#endif
     2035#endif
     2036
     2037#ifdef INCL_WINSOCK_API_TYPEDEFS
     2038TypeDef LPFN_WSAENUMNAMESPACEPROVIDERSA = *Function(ByRef BufferLength As DWord, ByRef nspBuffer As WSANAMESPACE_INFOA) As Long
     2039TypeDef LPFN_WSAENUMNAMESPACEPROVIDERSW = *Function(ByRef BufferLength As DWord, ByRef nspBuffer As WSANAMESPACE_INFOW) As Long
     2040#ifdef UNICODE
     2041TypeDef LPFN_WSAENUMNAMESPACEPROVIDERS = LPFN_WSAENUMNAMESPACEPROVIDERSW
     2042#else
     2043TypeDef LPFN_WSAENUMNAMESPACEPROVIDERS = LPFN_WSAENUMNAMESPACEPROVIDERSA
     2044#endif
     2045#endif
     2046
     2047#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     2048Declare Function WSAGetServiceClassNameByClassIdA Lib "ws2_32" (ByRef ServiceClassId As GUID, ServiceClassName As PSTR, ByRef BufferLength As DWord) As Long
     2049Declare Function WSAGetServiceClassNameByClassIdW Lib "ws2_32" (ByRef ServiceClassId As GUID, ServiceClassName As PWSTR, ByRef BufferLength As DWord) As Long
     2050#ifdef UNICODE
     2051Declare Function WSAGetServiceClassNameByClassId Lib "ws2_32" Alias "WSAGetServiceClassNameByClassIdW" (ByRef ServiceClassId As GUID, ServiceClassName As PWSTR, ByRef BufferLength As DWord) As Long
     2052#else
     2053Declare Function WSAGetServiceClassNameByClassId Lib "ws2_32" Alias "WSAGetServiceClassNameByClassIdA" (ByRef ServiceClassId As GUID, ServiceClassName As PSTR, ByRef BufferLength As DWord) As Long
     2054#endif
     2055#endif
     2056
     2057#ifdef INCL_WINSOCK_API_TYPEDEFS
     2058TypeDef LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA = *Function(ByRef ServiceClassId As GUID, ServiceClassName As PSTR, ByRef BufferLength As DWord) As Long
     2059TypeDef LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW = *Function(ByRef ServiceClassId As GUID, ServiceClassName As PWSTR, ByRef BufferLength As DWord) As Long
     2060#ifdef UNICODE
     2061TypeDef LPFN_WSAGETSERVICECLASSNAMEBYCLASSID = LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW
     2062#else
     2063TypeDef LPFN_WSAGETSERVICECLASSNAMEBYCLASSID = LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA
     2064#endif
     2065#endif
     2066
     2067#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     2068Declare Function WSASetServiceA Lib "ws2_32" (ByRef qsRegInfo As WSAQUERYSETA, essoperation As WSAESETSERVICEOP, ControlFlags As DWord) As Long
     2069Declare Function WSASetServiceW Lib "ws2_32" (ByRef qsRegInfo As WSAQUERYSETW, essoperation As WSAESETSERVICEOP, ControlFlags As DWord) As Long
     2070#ifdef UNICODE
     2071Declare Function WSASetService Lib "ws2_32" Alias "WSASetServiceW" (ByRef qsRegInfo As WSAQUERYSET, essoperation As WSAESETSERVICEOP, ControlFlags As DWord) As Long
     2072#else
     2073Declare Function WSASetService Lib "ws2_32" Alias "WSASetServiceA" (ByRef qsRegInfo As WSAQUERYSET, essoperation As WSAESETSERVICEOP, ControlFlags As DWord) As Long
     2074#endif
     2075#endif
     2076
     2077#ifdef INCL_WINSOCK_API_TYPEDEFS
     2078TypeDef LPFN_WSASETSERVICEA = *Function(ByRef qsRegInfo As WSAQUERYSETA, essoperation As WSAESETSERVICEOP, ControlFlags As DWord) As Long
     2079TypeDef LPFN_WSASETSERVICEW = *Function(ByRef qsRegInfo As WSAQUERYSETW, essoperation As WSAESETSERVICEOP, ControlFlags As DWord) As Long
     2080#ifdef UNICODE
     2081TypeDef LPFN_WSASETSERVICE = LPFN_WSASETSERVICEW
     2082#else
     2083TypeDef LPFN_WSASETSERVICE = LPFN_WSASETSERVICEA
     2084#endif
     2085#endif
     2086
     2087#ifndef NO_INCL_WINSOCK_API_PROTOTYPES
     2088Declare Function WSAProviderConfigChange Lib "ws2_32" (ByRef NotificationHandle As HANDLE, ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     2089#endif
     2090
     2091#ifdef INCL_WINSOCK_API_TYPEDEFS
     2092TypeDef LPFN_WSAPROVIDERCONFIGCHANGE = *Function(ByRef NotificationHandle As HANDLE, ByRef Overlapped As WSAOVERLAPPED, lpCompletionRoutine As LPWSAOVERLAPPED_COMPLETION_ROUTINE) As Long
     2093#endif
     2094
     2095' Microsoft Windows Extended data types
     2096TypeDef SOCKADDR_IN = sockaddr_in
     2097TypeDef PSOCKADDR_IN = *sockaddr_in
     2098TypeDef LPSOCKADDR_IN = *sockaddr_in
     2099
     2100TypeDef LINGER = linger
     2101TypeDef PLINGER = *linger
     2102TypeDef LPLINGER = *linger
     2103
     2104TypeDef IN_ADDR = in_addr
     2105TypeDef PIN_ADDR = *in_addr
     2106TypeDef LPIN_ADDR = *in_addr
     2107
     2108TypeDef FD_SET = fd_set
     2109TypeDef PFD_SET = *fd_set
     2110TypeDef LPFD_SET = *fd_set
     2111
     2112TypeDef HOSTENT = hostent
     2113TypeDef PHOSTENT = *hostent
     2114TypeDef LPHOSTENT = *hostent
     2115
     2116TypeDef SERVENT = servent
     2117TypeDef PSERVENT = *servent
     2118TypeDef LPSERVENT = *servent
     2119
     2120TypeDef PROTOENT = protoent
     2121TypeDef PPROTOENT = *protoent
     2122TypeDef LPPROTOENT = *protoent
     2123
     2124TypeDef TIMEVAL = timeval
     2125TypeDef PTIMEVAL = *timeval
     2126TypeDef LPTIMEVAL = *timeval
     2127
     2128' Windows message parameter composition and decomposition macros.
     2129Const WSAMAKEASYNCREPLY(buflen, error) = MAKELONG(buflen, error)
     2130Const WSAMAKESELECTREPLY(event, error) = MAKELONG(event, error)
     2131Const WSAGETASYNCBUFLEN(lParam) = LOWORD(lParam)
     2132Const WSAGETASYNCERROR(lParam) = HIWORD(lParam)
     2133Const WSAGETSELECTEVENT(lParam) = LOWORD(lParam)
     2134Const WSAGETSELECTERROR(lParam) = HIWORD(lParam)
     2135
     2136#ifdef IPV6STRICT
     2137'#include <wsipv6ok.ab>
     2138#endif
     2139
     2140#endif
Note: See TracChangeset for help on using the changeset viewer.