THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.
1 Introduction 1
2 Intended Audience 2
3 Document Organization 2
4 Status of This Specification 2
5 Document Version Conventions 3
6 New And/Or Different in Version 2.2.1 3
7 New And/Or Different in Version 2.2.2 3
8 Summary of New Concepts, Additions and Changes for WinSock 2 4
9 WinSock 2 Architecture 4
10 Simultaneous Access to Multiple Transport Protocols 4
11 Backwards Compatibility For WinSock 1.1 Applications 4
12 Source Code Compatibility 4
13 Binary Compatibility 5
14 Making Transport Protocols Available To WinSock 5
15 Layered Protocols and Protocol Chains 6
16 Using Multiple Protocols 6
17 Multiple Provider Restrictions on select() 7
18 Function Extension Mechanism 7
19 Debug and Trace Facilities 8
20 Protocol Independent Name Resolution 8
21 Overlapped I/O and Event Objects 8
22 Event Objects 9
23 Receiving Completion Indications 9
24 Blocking and Waiting for Completion Indication 9
25 Polling for Completion Indication 10
26 Using socket I/O completion routines 10
27 Summary of overlapped completion indication mechanisms 10
28 WSAOVERLAPPED Details 10
29 Asynchronous Notification Using Event Objects 11
30 Quality of Service 12
31 The QOS Structure 13
32 QOS Templates 15
33 Default Values 16
34 Socket Groups 16
35 Shared Sockets 17
36 Enhanced Functionality During Connection Setup and Teardown 17
37 Extended Byte Order Conversion Routines 18
38 Support for Scatter/Gather I/O 18
39 Protocol-Independent Multicast and Multipoint 18
40 Summary of New Socket Options 19
41 Summary of New Socket Ioctl Opcodes 19
42 Summary of New Functions 21
43 Generic Data Transport Functions 21
44 Name Registration and Resolution Functions 21
45 Windows Sockets Programming Considerations 23
46 Deviation from BSD Sockets 23
47 Socket Data Type 23
48 select() and FD_* 23
49 Error codes - errno, h_errno & WSAGetLastError() 23
50 Pointers 24
51 Renamed functions 24
52 close() and closesocket() 24
53 ioctl() and ioctlsocket()/WSAIoctl() 24
54 Maximum number of sockets supported 25
55 Include files 25
56 Return values on function failure 25
57 Raw Sockets 25
58 Byte Ordering 25
59 WinSock 1.1 Compatibility Issues 26
60 Default state for a socket’s overlapped attribute 26
61 Winsock 1.1 Blocking routines & EINPROGRESS 26
62 Graceful shutdown, linger options and socket closure 28
63 Out-Of-Band data 29
64 Protocol Independent OOB data 29
65 OOB data in TCP 30
66 Summary of WinSock 2 Functions 31
67 BSD Socket Functions 31
68 Microsoft Windows-specific Extension Functions 32
69 SOCKET LIBRARY REFERENCE 35
70 accept() 35
71 bind() 37
72 closesocket() 39
73 connect() 41
74 getpeername() 45
75 getsockname() 46
76 getsockopt() 48
77 htonl() 53
78 htons() 54
79 ioctlsocket() 55
80 listen() 57
81 ntohl() 59
82 ntohs() 60
83 recv() 61
84 recvfrom() 64
85 select() 67
86 send() 70
87 sendto() 73
88 setsockopt() 77
89 shutdown() 81
90 socket() 83
91 WSAAccept() 86
92 WSAAsyncSelect() 90
93 WSACancelBlockingCall() 98
94 WSACleanup() 100
95 WSACloseEvent() 101
96 WSAConnect() 102
97 WSACreateEvent() 106
98 WSADuplicateSocket() 107
99 WSAEnumNetworkEvents() 109
100 WSAEnumProtocols() 112
101 WSAEventSelect() 117
102 WSAGetLastError() 122
103 WSAGetOverlappedResult() 123
104 WSAGetQOSByName() 125
105 WSAHtonl() 126
106 WSAHtons() 127
107 WSAIoctl() 128
108 WSAIsBlocking() 138
109 WSAJoinLeaf() 139
110 WSANtohl() 144
111 WSANtohs() 145
112 WSARecv() 146
113 WSARecvDisconnect() 152
114 WSARecvFrom() 154
115 WSAResetEvent() 160
116 WSASend() 161
117 WSASendDisconnect() 166
118 WSASendTo() 168
119 WSASetBlockingHook() 174
120 WSASetEvent() 177
121 WSASetLastError() 178
122 WSASocket() 179
123 WSAStartup() 183
124 WSAUnhookBlockingHook() 187
125 WSAWaitForMultipleEvents() 188
126 WSAProviderConfigChange() 190
127 Name Resolution and Registration 192
128 Protocol-Independent Name Resolution 192
129 Name Resolution Model 192
130 Types of Name Spaces 192
131 Name Space Organization 193
132 Name Space Provider Architecture 193
133 Summary of Name Resolution Functions 194
134 Service Installation 194
135 Client Query 195
136 Helper Functions 195
137 Name Resolution Data Structures 196
138 Query-Related Data Structures 196
139 Service Class Data Structures 197
140 Name Resolution Function Reference 198
141 WSAAddressToString() 198
142 WSAEnumNameSpaceProviders() 200
143 WSAGetServiceClassInfo 202
144 WSAGetServiceClassNameByClassId() 203
145 WSAInstallServiceClass() 204
146 WSALookupServiceBegin() 205
147 WSALookupServiceEnd() 208
148 WSALookupServiceNext() 209
149 WSARemoveServiceClass() 212
4.2.10. WSASetService() 213
150 WSAStringToAddress() 216
151 WinSock 1.1 Compatibile Name Resolution for TCP/IP 217
152 Introduction 217
153 Basic Approach 217
154 getprotobyname and getprotobynumber 217
155 getservbyname() and getservbyport() 218
156 gethostbyname() 218
157 gethostbyaddr() 218
158 gethostname() 218
159 WinSock 1.1 Compatible Name Resolution Reference 219
160 gethostbyaddr() 219
161 gethostbyname() 221
162 gethostname() 223
163 getprotobyname() 224
164 getprotobynumber() 226
165 getservbyname() 227
166 getservbyport() 229
167 inet_addr() 231
168 inet_ntoa() 232
169 WSAAsyncGetHostByAddr() 233
170 WSAAsyncGetHostByName() 236
171 WSAAsyncGetProtoByName() 239
172 WSAAsyncGetProtoByNumber() 242
173 WSAAsyncGetServByName() 245
174 WSAAsyncGetServByPort() 248
175 WSACancelAsyncRequest() 251
Appendix A. Error Codes and Header Files and Data Types 253
A.1 Error Codes 253
A.1.1 Error Codes - Brief Description 253
A.1.2 Error Codes - Extended Description 255
A.2 Header Files 261
A.2.1 Berkeley Header Files 261
A.2.2 WinSock Header File - Winsock2.h 262
A.2.3 Sizes of Data Types 263
Appendix B. Multipoint and Multicast Semantics 264
B.1. Multipoint and Multicast Introduction 264
B.2 Multipoint Taxonomy 264
B.3 WinSock 2 Interface Elements for Multipoint and Multicast 265
B.3.1. Attributes in WSAPROTOCOL_INFO struct 265
B.3.2. Flag bits for WSASocket() 265
B.3.3. SIO_MULTIPOINT_LOOP command code for WSAIoctl() 266
B.3.4. SIO_MULTICAST_SCOPE command code for WSAIoctl() 266
B.3.5. WSAJoinLeaf() 266
B.4. Semantics for joining multipoint leaves 266
B.4.1. Using WSAJoinLeaf() 267
B.5. Semantic differences between multipoint sockets and regular sockets 268
B.6. How existing multipoint protocols support these extensions 268
B.6.1. IP multicast 268
B.6.2. ATM Point to Multipoint 269
Appendix C. The Lame List 270
Appendix D. For Further Reference 278
D.1 Networking books: 278
D.2 Windows Sockets programming books: 278
The following individuals moderated the WinSock 2 effort as a whole and provided the framework, technical guidance and administrative mechanisms for WinSock Version 2.
Special thanks to Microsoft and Intel for the amount of time these companies gave to the specification and especially to Dave Treadwell and Keith Moore at Microsoft and Dave Andersen and Charlie Tai at Intel for their considerable editorial efforts on the WinSock 2 specifications.