OSDN Git Service

789ab040420e202fbcc8cc2ef03b2e049385869c
[mingw/mingw-org-wsl.git] / w32api / include / winsock.h
1 /*
2  * winsock.h
3  *
4  * Definitions for WinSock Version 1.1 API.
5  *
6  *
7  * $Id$
8  *
9  * Adaptation by Anders Norlander <anorland@hem2.passagen.se>
10  * Copyright (C) 1998-2004, 2012, 2016, 2017, MinGW.org Project.
11  *
12  * Portions Copyright (C) 1980, 1983, 1988, 1993
13  * The Regents of the University of California.  All rights reserved.
14  *
15  * Portions Copyright (C) 1993 by Digital Equipment Corporation.
16  *
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions
20  * are met:
21  * 1. Redistributions of source code must retain the above copyright
22  *    notices, this list of conditions and the following disclaimer.
23  * 2. Redistributions in binary form must reproduce the above copyright
24  *    notice, this list of conditions and the following disclaimer in the
25  *    documentation and/or other materials provided with the distribution.
26  * 3. Neither the name of the University nor the names of its contributors
27  *    may be used to endorse or promote products derived from this software
28  *    without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
31  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40  * SUCH DAMAGE.
41  *
42  */
43 #ifndef _WINSOCK_H
44 #pragma GCC system_header
45 #define _WINSOCK_H
46
47 #define _GNU_H_WINDOWS32_SOCKETS
48 #define __WINSOCK_H_SOURCED__ 1
49
50 #include <windows.h>
51 #include <winerror.h>
52 #include <sys/bsdtypes.h>
53 #include <sys/time.h>
54
55 #ifndef WINSOCK_API_LINKAGE
56 /* Historically, this was defined (and used) within <winsock2.h>, but not
57  * <winsock.h>, to qualify function declarations which are common to both;
58  * for consistency, we now define, (and subsequently use it here), while
59  * preserving the effect of its previous absence, within <winsock.h>, by
60  * ensuring that it expands to nothing in this context.
61  *
62  * FIXME: Is this logical?  Perhaps <winsock.h> should adopt the effect,
63  * exactly as it was previously implemented exclusively in <winsock2.h>?
64  */
65 #if defined _WINSOCK2_H && defined __W32API_USE_DLLIMPORT__
66 /* To preserve backward compatibility, DECLSPEC_IMPORT option is
67  * available only to WinSock v2 clients, which request it...
68  */
69 #define WINSOCK_API_LINKAGE  DECLSPEC_IMPORT
70
71 #else
72 /* ...whereas WinSock v1.1 clients, and those WinSock v2 clients which
73  * do not request DECLSPEC_IMPORT, will always use default linkage.
74  */
75 #define WINSOCK_API_LINKAGE
76 #endif
77 #endif
78
79 #if ! defined _USE_SYS_TYPES_FD_SET && defined USE_SYS_TYPES_FD_SET
80 /* Originally defined by the deprecated name, USE_SYS_TYPES_FD_SET, users
81  * may specify this to suppress warnings, in the event that (incompatible)
82  * fd_set manipulation macros may have been inherited from <sys/types.h>;
83  * accommodate use of the deprecated feature test name.
84  */
85 #warning "Feature test macro USE_SYS_TYPES_FD_SET is deprecated."
86 #warning "Use the _USE_SYS_TYPES_FD_SET feature test macro instead."
87 #define _USE_SYS_TYPES_FD_SET  1
88 #endif
89
90 #ifndef __WINSOCK2_DEPRECATED
91 /* Some of the WinSock v1.1 declarations have become deprecated in
92  * WinSock v2.  If <winsock2.h> has been included, this deprecation
93  * attribute macro should already have been defined; if not, we now
94  * define it to do nothing.
95  */
96 #define __WINSOCK2_DEPRECATED
97 #endif
98
99 _BEGIN_C_DECLS
100
101 typedef u_int  SOCKET;
102
103 #ifndef FD_SETSIZE
104 #define FD_SETSIZE                                64
105 #endif
106
107 /* shutdown() how types */
108 #define SD_RECEIVE                              0x00
109 #define SD_SEND                                 0x01
110 #define SD_BOTH                                 0x02
111
112 #ifndef _SYS_TYPES_FD_SET
113 /* fd_set may have been defined by the newlib <sys/types.h>, if the
114  * internal __USE_W32_SOCKETS feature test has not been enabled.
115  */
116 #undef fd_set
117 typedef
118 struct fd_set
119 { u_int         fd_count;
120   SOCKET        fd_array[FD_SETSIZE];
121 } fd_set;
122
123 int PASCAL __WSAFDIsSet (SOCKET, fd_set *);
124
125 #ifndef FD_CLR
126 #define FD_CLR( fd, set )  do                                   \
127   { u_int __i;                                                  \
128     for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++)    \
129     { if (((fd_set *)(set))->fd_array[__i] == (fd))             \
130       { while (__i < ((fd_set *)(set))->fd_count-1)             \
131         { ((fd_set *)(set))->fd_array[__i]                      \
132             = ((fd_set *)(set))->fd_array[__i + 1]; __i++;      \
133         }                                                       \
134         ((fd_set *)(set))->fd_count--;                          \
135         break;                                                  \
136       }                                                         \
137     }                                                           \
138   } while (0)
139 #endif  /* ! defined FD_CLR */
140
141 #ifndef FD_SET
142 #define FD_SET( fd, set )  do                                              \
143   { if (((fd_set *)(set))->fd_count < FD_SETSIZE)                          \
144        ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++] = (fd);  \
145   } while (0)
146 #endif  /* ! defined FD_SET */
147
148 #ifndef FD_ZERO
149 #define FD_ZERO( set )  (((fd_set *)(set))->fd_count = 0)
150 #endif  /* ! defined FD_ZERO */
151
152 #ifndef FD_ISSET
153 #define FD_ISSET( fd, set )  __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
154 #endif  /* ! defined FD_ISSET */
155
156 #elif ! defined _USE_SYS_TYPES_FD_SET
157 /* Definitions from <sys/types.h> probably aren't what the user wants;
158  * if they know what they are doing, and they are sure that this really
159  * is what they want, then they may enable the _USE_SYS_TYPES_FD_SET
160  * feature test macro, to suppress this warning.
161  */
162 #warning "fd_set and associated macros have been defined in <sys/types.h>"
163 #warning "Your <sys/types.h> may cause runtime problems with W32 sockets."
164 #endif  /* !_SYS_TYPES_FD_SET */
165
166 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
167
168 struct hostent
169 { char           *h_name;
170   char          **h_aliases;
171   short           h_addrtype;
172   short           h_length;
173 # define          h_addr  h_addr_list[0]
174   char          **h_addr_list;
175 };
176
177 struct linger
178 { u_short         l_onoff;
179   u_short         l_linger;
180 };
181
182 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
183
184 #define IOCPARM_MASK                          0x7F
185 #define IOC_VOID                        0x20000000
186 #define IOC_OUT                         0x40000000
187 #define IOC_IN                          0x80000000
188 #define IOC_INOUT                   (IOC_IN | IOC_OUT)
189
190 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
191
192 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
193 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
194 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
195
196 #define FIONBIO                 _IOW('f', 126, u_long)
197
198 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
199
200 #define FIONREAD                _IOR('f', 127, u_long)
201 #define FIOASYNC                _IOW('f', 125, u_long)
202 #define SIOCSHIWAT              _IOW('s',  0, u_long)
203 #define SIOCGHIWAT              _IOR('s',  1, u_long)
204 #define SIOCSLOWAT              _IOW('s',  2, u_long)
205 #define SIOCGLOWAT              _IOR('s',  3, u_long)
206 #define SIOCATMARK              _IOR('s',  7, u_long)
207
208 #if ! ( defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
209
210 struct netent
211 { char           *n_name;
212   char          **n_aliases;
213   short           n_addrtype;
214   u_long          n_net;
215 };
216
217 struct servent
218 { char           *s_name;
219   char          **s_aliases;
220   short           s_port;
221   char           *s_proto;
222 };
223
224 struct protoent
225 { char           *p_name;
226   char          **p_aliases;
227   short           p_proto;
228 };
229
230 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
231
232 #define IPPROTO_IP                                 0
233 #define IPPROTO_ICMP                               1
234 #define IPPROTO_IGMP                               2
235 #define IPPROTO_GGP                                3
236 #define IPPROTO_TCP                                6
237 #define IPPROTO_PUP                               12
238 #define IPPROTO_UDP                               17
239 #define IPPROTO_IDP                               22
240 #define IPPROTO_ND                                77
241
242 #define IPPROTO_RAW                              255
243 #define IPPROTO_MAX                              256
244
245 #define IPPORT_ECHO                                7
246 #define IPPORT_DISCARD                             9
247 #define IPPORT_SYSTAT                             11
248 #define IPPORT_DAYTIME                            13
249 #define IPPORT_NETSTAT                            15
250 #define IPPORT_FTP                                21
251 #define IPPORT_TELNET                             23
252 #define IPPORT_SMTP                               25
253 #define IPPORT_TIMESERVER                         37
254 #define IPPORT_NAMESERVER                         42
255 #define IPPORT_WHOIS                              43
256 #define IPPORT_MTP                                57
257 #define IPPORT_TFTP                               69
258 #define IPPORT_RJE                                77
259 #define IPPORT_FINGER                             79
260 #define IPPORT_TTYLINK                            87
261 #define IPPORT_SUPDUP                             95
262 #define IPPORT_EXECSERVER                        512
263 #define IPPORT_LOGINSERVER                       513
264 #define IPPORT_CMDSERVER                         514
265 #define IPPORT_EFSSERVER                         520
266 #define IPPORT_BIFFUDP                           512
267 #define IPPORT_WHOSERVER                         513
268 #define IPPORT_ROUTESERVER                       520
269 #define IPPORT_RESERVED                         1024
270
271 #define IMPLINK_IP                               155
272 #define IMPLINK_LOWEXPER                         156
273 #define IMPLINK_HIGHEXPER                        158
274
275 struct in_addr
276 #define s_addr                                S_un.S_addr
277 #define s_host                                S_un.S_un_b.s_b2
278 #define s_net                                 S_un.S_un_b.s_b1
279 #define s_imp                                 S_un.S_un_w.s_w2
280 #define s_impno                               S_un.S_un_b.s_b4
281 #define s_lh                                  S_un.S_un_b.s_b3
282 { union
283   { struct { u_char s_b1,s_b2,s_b3,s_b4; }      S_un_b;
284     struct { u_short s_w1,s_w2; }               S_un_w;
285     u_long                                      S_addr;
286   }                                           S_un;
287 };
288
289 #define IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
290 #define IN_CLASSA_NET                     0xFF000000
291 #define IN_CLASSA_NSHIFT                          24
292 #define IN_CLASSA_HOST                    0x00FFFFFF
293 #define IN_CLASSA_MAX                            128
294 #define IN_CLASSB(i)        (((long)(i) & 0xC0000000) == 0x80000000)
295 #define IN_CLASSB_NET                     0xFFFF0000
296 #define IN_CLASSB_NSHIFT                          16
297 #define IN_CLASSB_HOST                    0x0000FFFF
298 #define IN_CLASSB_MAX                          65536
299 #define IN_CLASSC(i)        (((long)(i) & 0xE0000000) == 0xC0000000)
300 #define IN_CLASSC_NET                     0xFFFFFF00
301 #define IN_CLASSC_NSHIFT                           8
302 #define IN_CLASSC_HOST                          0xFF
303 #define INADDR_ANY                        (u_long)(0)
304 #define INADDR_LOOPBACK                   0x7F000001
305 #define INADDR_BROADCAST         (u_long)(0xFFFFFFFF)
306 #define INADDR_NONE                       0xFFFFFFFF
307
308 struct sockaddr_in
309 { short                  sin_family;
310   u_short                sin_port;
311   struct in_addr         sin_addr;
312   char                   sin_zero[8];
313 };
314
315 #define WSADESCRIPTION_LEN                       256
316 #define WSASYS_STATUS_LEN                        128
317
318 typedef
319 struct WSAData
320 { WORD                   wVersion;
321   WORD                   wHighVersion;
322   char                   szDescription[WSADESCRIPTION_LEN+1];
323   char                   szSystemStatus[WSASYS_STATUS_LEN+1];
324   unsigned short         iMaxSockets;
325   unsigned short         iMaxUdpDg;
326   char                  *lpVendorInfo;
327 } WSADATA, *LPWSADATA;
328
329 #ifndef __INSIDE_MSYS__
330
331 #define IP_OPTIONS                                 1
332 #define SO_DEBUG                                   1
333 #define SO_ACCEPTCONN                              2
334 #define SO_REUSEADDR                               4
335 #define SO_KEEPALIVE                               8
336 #define SO_DONTROUTE                              16
337 #define SO_BROADCAST                              32
338 #define SO_USELOOPBACK                            64
339 #define SO_LINGER                                128
340 #define SO_OOBINLINE                             256
341
342 #define SO_DONTLINGER                    (u_int)(~SO_LINGER)
343
344 #define SO_SNDBUF                             0x1001
345 #define SO_RCVBUF                             0x1002
346 #define SO_SNDLOWAT                           0x1003
347 #define SO_RCVLOWAT                           0x1004
348 #define SO_SNDTIMEO                           0x1005
349 #define SO_RCVTIMEO                           0x1006
350 #define SO_ERROR                              0x1007
351 #define SO_TYPE                               0x1008
352
353 #endif  /* !__INSIDE_MSYS__ */
354
355 /* The following IP defines are specific to WinSock v1.1 (wsock32.dll).
356  * They may cause errors, or produce unexpected results, if exposed when
357  * compiling application code which is intended to use the getsockopts(),
358  * or setsockopts() APIs, as exported from the WinSock v2 system library,
359  * ws2_32.dll.  Please refer to <ws2tcpip.h> for further information.
360  */
361 #define IP_MULTICAST_IF                            2
362 #define IP_MULTICAST_TTL                           3
363 #define IP_MULTICAST_LOOP                          4
364 #define IP_ADD_MEMBERSHIP                          5
365 #define IP_DROP_MEMBERSHIP                         6
366
367 #define IP_DEFAULT_MULTICAST_TTL                   1
368 #define IP_DEFAULT_MULTICAST_LOOP                  1
369 #define IP_MAX_MEMBERSHIPS                        20
370
371 struct ip_mreq
372 { struct in_addr         imr_multiaddr;
373   struct in_addr         imr_interface;
374 };
375
376 #define INVALID_SOCKET                   (SOCKET)(~0)
377 #define SOCKET_ERROR                             (-1)
378 #define SOCK_STREAM                                1
379 #define SOCK_DGRAM                                 2
380 #define SOCK_RAW                                   3
381 #define SOCK_RDM                                   4
382 #define SOCK_SEQPACKET                             5
383 #define TCP_NODELAY                           0x0001
384 #define AF_UNSPEC                                  0
385 #define AF_UNIX                                    1
386 #define AF_INET                                    2
387 #define AF_IMPLINK                                 3
388 #define AF_PUP                                     4
389 #define AF_CHAOS                                   5
390 #define AF_IPX                                     6
391 #define AF_NS                                      6
392 #define AF_ISO                                     7
393
394 #define AF_OSI                                AF_ISO
395
396 #define AF_ECMA                                    8
397 #define AF_DATAKIT                                 9
398 #define AF_CCITT                                  10
399 #define AF_SNA                                    11
400 #define AF_DECnet                                 12
401 #define AF_DLI                                    13
402 #define AF_LAT                                    14
403 #define AF_HYLINK                                 15
404 #define AF_APPLETALK                              16
405 #define AF_NETBIOS                                17
406 #define AF_VOICEVIEW                              18
407 #define AF_FIREFOX                                19
408 #define AF_UNKNOWN1                               20
409 #define AF_BAN                                    21
410 #define AF_ATM                                    22
411 #define AF_INET6                                  23
412
413 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
414
415 #define AF_MAX                                    24
416
417 struct sockaddr
418 { u_short                sa_family;
419   char                   sa_data[14];
420 };
421
422 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
423
424 struct sockproto
425 { u_short                sp_family;
426   u_short                sp_protocol;
427 };
428
429 #define PF_UNSPEC                          AF_UNSPEC
430 #define PF_UNIX                              AF_UNIX
431 #define PF_INET                              AF_INET
432 #define PF_IMPLINK                        AF_IMPLINK
433 #define PF_PUP                                AF_PUP
434 #define PF_CHAOS                            AF_CHAOS
435 #define PF_NS                                  AF_NS
436 #define PF_IPX                                AF_IPX
437 #define PF_ISO                                AF_ISO
438 #define PF_OSI                                AF_OSI
439 #define PF_ECMA                              AF_ECMA
440 #define PF_DATAKIT                        AF_DATAKIT
441 #define PF_CCITT                            AF_CCITT
442 #define PF_SNA                                AF_SNA
443 #define PF_DECnet                          AF_DECnet
444 #define PF_DLI                                AF_DLI
445 #define PF_LAT                                AF_LAT
446 #define PF_HYLINK                          AF_HYLINK
447 #define PF_APPLETALK                    AF_APPLETALK
448 #define PF_VOICEVIEW                    AF_VOICEVIEW
449 #define PF_FIREFOX                        AF_FIREFOX
450 #define PF_UNKNOWN1                      AF_UNKNOWN1
451 #define PF_BAN                                AF_BAN
452 #define PF_ATM                                AF_ATM
453 #define PF_INET6                            AF_INET6
454 #define PF_MAX                                AF_MAX
455
456 #define SOL_SOCKET                            0xFFFF
457 #define SOMAXCONN                                  5
458
459 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
460
461 #define MSG_OOB                                    1
462 #define MSG_PEEK                                   2
463 #define MSG_DONTROUTE                              4
464
465 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
466
467 #define MSG_MAXIOVLEN                             16
468 #define MSG_PARTIAL                           0x8000
469 #define MAXGETHOSTSTRUCT                        1024
470
471 #define FD_READ                                    1
472 #define FD_WRITE                                   2
473 #define FD_OOB                                     4
474 #define FD_ACCEPT                                  8
475 #define FD_CONNECT                                16
476 #define FD_CLOSE                                  32
477
478 #define WSANO_ADDRESS                   WSANO_DATA
479
480 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
481
482 #define h_errno                         WSAGetLastError()
483 #define HOST_NOT_FOUND                  WSAHOST_NOT_FOUND
484 #define TRY_AGAIN                       WSATRY_AGAIN
485 #define NO_RECOVERY                     WSANO_RECOVERY
486 #define NO_DATA                         WSANO_DATA
487 #define NO_ADDRESS                      WSANO_ADDRESS
488
489 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
490
491 WINSOCK_API_LINKAGE SOCKET PASCAL accept (SOCKET, struct sockaddr *, int *);
492
493 WINSOCK_API_LINKAGE int PASCAL bind (SOCKET, const struct sockaddr *, int);
494 WINSOCK_API_LINKAGE int PASCAL closesocket (SOCKET);
495 WINSOCK_API_LINKAGE int PASCAL connect (SOCKET, const struct sockaddr *, int);
496 WINSOCK_API_LINKAGE int PASCAL ioctlsocket (SOCKET, long, u_long *);
497 WINSOCK_API_LINKAGE int PASCAL getpeername (SOCKET, struct sockaddr *, int *);
498 WINSOCK_API_LINKAGE int PASCAL getsockname (SOCKET, struct sockaddr *, int *);
499 WINSOCK_API_LINKAGE int PASCAL getsockopt (SOCKET, int, int, char *, int *);
500
501 WINSOCK_API_LINKAGE unsigned long PASCAL inet_addr (const char *);
502
503 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (char *) inet_ntoa (struct in_addr);
504
505 WINSOCK_API_LINKAGE int PASCAL listen (SOCKET, int);
506 WINSOCK_API_LINKAGE int PASCAL recv (SOCKET, char *, int, int);
507 WINSOCK_API_LINKAGE int PASCAL recvfrom (SOCKET, char *, int, int, struct sockaddr *, int *);
508 WINSOCK_API_LINKAGE int PASCAL send (SOCKET, const char *, int, int);
509 WINSOCK_API_LINKAGE int PASCAL sendto (SOCKET, const char *, int, int, const struct sockaddr *, int);
510 WINSOCK_API_LINKAGE int PASCAL setsockopt (SOCKET, int, int, const char *, int);
511 WINSOCK_API_LINKAGE int PASCAL shutdown (SOCKET, int);
512
513 WINSOCK_API_LINKAGE SOCKET PASCAL socket (int, int, int);
514
515 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct hostent *)  gethostbyaddr (const char *, int, int);
516 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct hostent *)  gethostbyname (const char *);
517 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct servent *)  getservbyport (int, const char *);
518 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct servent *)  getservbyname (const char *, const char *);
519 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct protoent *) getprotobynumber (int);
520 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct protoent *) getprotobyname (const char *);
521
522 WINSOCK_API_LINKAGE int PASCAL WSAStartup (WORD, LPWSADATA);
523 WINSOCK_API_LINKAGE int PASCAL WSACleanup (void);
524 WINSOCK_API_LINKAGE void PASCAL WSASetLastError (int);
525 WINSOCK_API_LINKAGE int PASCAL WSAGetLastError (void);
526
527 /* The following four pseudo-blocking functions are provided
528  * to support WinSock v1.1, but have been marked as deprecated
529  * in WinSock v2; they remain available, but it is recommended
530  * that threads should be used instead!
531  */
532 WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void) __WINSOCK2_DEPRECATED;
533 WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void) __WINSOCK2_DEPRECATED;
534 WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC) __WINSOCK2_DEPRECATED;
535 WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void) __WINSOCK2_DEPRECATED;
536
537 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByName (HWND, u_int, const char *, const char *, char *, int);
538 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByPort (HWND, u_int, int, const char *, char *, int);
539 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetProtoByName (HWND, u_int, const char *, char *, int);
540 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetProtoByNumber (HWND, u_int, int, char *, int);
541 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetHostByName (HWND, u_int, const char *, char *, int);
542 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetHostByAddr (HWND, u_int, const char *, int, int, char *, int);
543
544 WINSOCK_API_LINKAGE int PASCAL WSACancelAsyncRequest (HANDLE);
545 WINSOCK_API_LINKAGE int PASCAL WSAAsyncSelect (SOCKET, HWND, u_int, long);
546
547 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
548
549 WINSOCK_API_LINKAGE u_long PASCAL htonl (u_long);
550 WINSOCK_API_LINKAGE u_long PASCAL ntohl (u_long);
551 WINSOCK_API_LINKAGE u_short PASCAL htons (u_short);
552 WINSOCK_API_LINKAGE u_short PASCAL ntohs (u_short);
553 WINSOCK_API_LINKAGE int PASCAL select (int nfds, fd_set *, fd_set *, fd_set *, const struct timeval *);
554 int PASCAL gethostname (char *, int );
555
556 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
557
558 #define WSAMAKEASYNCREPLY(b,e)                  MAKELONG(b,e)
559 #define WSAMAKESELECTREPLY(e,error)             MAKELONG(e,error)
560 #define WSAGETASYNCBUFLEN(l)                    LOWORD(l)
561 #define WSAGETASYNCERROR(l)                     HIWORD(l)
562 #define WSAGETSELECTEVENT(l)                    LOWORD(l)
563 #define WSAGETSELECTERROR(l)                    HIWORD(l)
564
565 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
566 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
567 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
568 typedef struct linger LINGER, *PLINGER, *LPLINGER;
569 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
570 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
571 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
572 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
573 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
574
575 _END_C_DECLS
576
577 /* MSDN documentation indicates that the MS-specific extensions exported
578  * from mswsock.dll, (i.e. the AcceptEx(), TransmitFile(), WSARecEx(), and
579  * GetAcceptExSockaddrs() functions), are declared in <mswsock.h>.  These
580  * extensions are not supported on Win9x or WinCE.  However, WinSock v1.1
581  * dependent code may expect that the declarations and associated defines
582  * will be in this header; thus we include <mswsock.h> here.
583  *
584  * When linking against the WinSock v1.1 library, wsock32.dll, the mswsock
585  * functions are automatically routed to mswsock.dll (on platforms which
586  * support it).  The WinSock v2 library, ws2_32.dll, does not contain any
587  * references to the mswsock extensions.
588  */
589 #include <mswsock.h>
590
591 #undef  __WINSOCK_H_SOURCED__
592 #endif  /* _WINSOCK_H: $RCSfile$: end of file */