OSDN Git Service

e0da4db940cf0dc7a26584b8be3930fc9b63b08f
[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 _BEGIN_C_DECLS
91
92 typedef u_int  SOCKET;
93
94 #ifndef FD_SETSIZE
95 #define FD_SETSIZE                                64
96 #endif
97
98 /* shutdown() how types */
99 #define SD_RECEIVE                              0x00
100 #define SD_SEND                                 0x01
101 #define SD_BOTH                                 0x02
102
103 #ifndef _SYS_TYPES_FD_SET
104 /* fd_set may have been defined by the newlib <sys/types.h>, if the
105  * internal __USE_W32_SOCKETS feature test has not been enabled.
106  */
107 #undef fd_set
108 typedef
109 struct fd_set
110 { u_int         fd_count;
111   SOCKET        fd_array[FD_SETSIZE];
112 } fd_set;
113
114 int PASCAL __WSAFDIsSet (SOCKET, fd_set *);
115
116 #ifndef FD_CLR
117 #define FD_CLR( fd, set )  do                                   \
118   { u_int __i;                                                  \
119     for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++)    \
120     { if (((fd_set *)(set))->fd_array[__i] == (fd))             \
121       { while (__i < ((fd_set *)(set))->fd_count-1)             \
122         { ((fd_set *)(set))->fd_array[__i]                      \
123             = ((fd_set *)(set))->fd_array[__i + 1]; __i++;      \
124         }                                                       \
125         ((fd_set *)(set))->fd_count--;                          \
126         break;                                                  \
127       }                                                         \
128     }                                                           \
129   } while (0)
130 #endif  /* ! defined FD_CLR */
131
132 #ifndef FD_SET
133 #define FD_SET( fd, set )  do                                              \
134   { if (((fd_set *)(set))->fd_count < FD_SETSIZE)                          \
135        ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++] = (fd);  \
136   } while (0)
137 #endif  /* ! defined FD_SET */
138
139 #ifndef FD_ZERO
140 #define FD_ZERO( set )  (((fd_set *)(set))->fd_count = 0)
141 #endif  /* ! defined FD_ZERO */
142
143 #ifndef FD_ISSET
144 #define FD_ISSET( fd, set )  __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
145 #endif  /* ! defined FD_ISSET */
146
147 #elif ! defined _USE_SYS_TYPES_FD_SET
148 /* Definitions from <sys/types.h> probably aren't what the user wants;
149  * if they know what they are doing, and they are sure that this really
150  * is what they want, then they may enable the _USE_SYS_TYPES_FD_SET
151  * feature test macro, to suppress this warning.
152  */
153 #warning "fd_set and associated macros have been defined in <sys/types.h>"
154 #warning "Your <sys/types.h> may cause runtime problems with W32 sockets."
155 #endif  /* !_SYS_TYPES_FD_SET */
156
157 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
158
159 struct hostent
160 { char           *h_name;
161   char          **h_aliases;
162   short           h_addrtype;
163   short           h_length;
164 # define          h_addr  h_addr_list[0]
165   char          **h_addr_list;
166 };
167
168 struct linger
169 { u_short         l_onoff;
170   u_short         l_linger;
171 };
172
173 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
174
175 #define IOCPARM_MASK                          0x7F
176 #define IOC_VOID                        0x20000000
177 #define IOC_OUT                         0x40000000
178 #define IOC_IN                          0x80000000
179 #define IOC_INOUT                   (IOC_IN | IOC_OUT)
180
181 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
182
183 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
184 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
185 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
186
187 #define FIONBIO                 _IOW('f', 126, u_long)
188
189 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
190
191 #define FIONREAD                _IOR('f', 127, u_long)
192 #define FIOASYNC                _IOW('f', 125, u_long)
193 #define SIOCSHIWAT              _IOW('s',  0, u_long)
194 #define SIOCGHIWAT              _IOR('s',  1, u_long)
195 #define SIOCSLOWAT              _IOW('s',  2, u_long)
196 #define SIOCGLOWAT              _IOR('s',  3, u_long)
197 #define SIOCATMARK              _IOR('s',  7, u_long)
198
199 #if ! ( defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
200
201 struct netent
202 { char           *n_name;
203   char          **n_aliases;
204   short           n_addrtype;
205   u_long          n_net;
206 };
207
208 struct servent
209 { char           *s_name;
210   char          **s_aliases;
211   short           s_port;
212   char           *s_proto;
213 };
214
215 struct protoent
216 { char           *p_name;
217   char          **p_aliases;
218   short           p_proto;
219 };
220
221 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
222
223 #define IPPROTO_IP                                 0
224 #define IPPROTO_ICMP                               1
225 #define IPPROTO_IGMP                               2
226 #define IPPROTO_GGP                                3
227 #define IPPROTO_TCP                                6
228 #define IPPROTO_PUP                               12
229 #define IPPROTO_UDP                               17
230 #define IPPROTO_IDP                               22
231 #define IPPROTO_ND                                77
232
233 #define IPPROTO_RAW                              255
234 #define IPPROTO_MAX                              256
235
236 #define IPPORT_ECHO                                7
237 #define IPPORT_DISCARD                             9
238 #define IPPORT_SYSTAT                             11
239 #define IPPORT_DAYTIME                            13
240 #define IPPORT_NETSTAT                            15
241 #define IPPORT_FTP                                21
242 #define IPPORT_TELNET                             23
243 #define IPPORT_SMTP                               25
244 #define IPPORT_TIMESERVER                         37
245 #define IPPORT_NAMESERVER                         42
246 #define IPPORT_WHOIS                              43
247 #define IPPORT_MTP                                57
248 #define IPPORT_TFTP                               69
249 #define IPPORT_RJE                                77
250 #define IPPORT_FINGER                             79
251 #define IPPORT_TTYLINK                            87
252 #define IPPORT_SUPDUP                             95
253 #define IPPORT_EXECSERVER                        512
254 #define IPPORT_LOGINSERVER                       513
255 #define IPPORT_CMDSERVER                         514
256 #define IPPORT_EFSSERVER                         520
257 #define IPPORT_BIFFUDP                           512
258 #define IPPORT_WHOSERVER                         513
259 #define IPPORT_ROUTESERVER                       520
260 #define IPPORT_RESERVED                         1024
261
262 #define IMPLINK_IP                               155
263 #define IMPLINK_LOWEXPER                         156
264 #define IMPLINK_HIGHEXPER                        158
265
266 struct in_addr
267 #define s_addr                                S_un.S_addr
268 #define s_host                                S_un.S_un_b.s_b2
269 #define s_net                                 S_un.S_un_b.s_b1
270 #define s_imp                                 S_un.S_un_w.s_w2
271 #define s_impno                               S_un.S_un_b.s_b4
272 #define s_lh                                  S_un.S_un_b.s_b3
273 { union
274   { struct { u_char s_b1,s_b2,s_b3,s_b4; }      S_un_b;
275     struct { u_short s_w1,s_w2; }               S_un_w;
276     u_long                                      S_addr;
277   }                                           S_un;
278 };
279
280 #define IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
281 #define IN_CLASSA_NET                     0xFF000000
282 #define IN_CLASSA_NSHIFT                          24
283 #define IN_CLASSA_HOST                    0x00FFFFFF
284 #define IN_CLASSA_MAX                            128
285 #define IN_CLASSB(i)        (((long)(i) & 0xC0000000) == 0x80000000)
286 #define IN_CLASSB_NET                     0xFFFF0000
287 #define IN_CLASSB_NSHIFT                          16
288 #define IN_CLASSB_HOST                    0x0000FFFF
289 #define IN_CLASSB_MAX                          65536
290 #define IN_CLASSC(i)        (((long)(i) & 0xE0000000) == 0xC0000000)
291 #define IN_CLASSC_NET                     0xFFFFFF00
292 #define IN_CLASSC_NSHIFT                           8
293 #define IN_CLASSC_HOST                          0xFF
294 #define INADDR_ANY                        (u_long)(0)
295 #define INADDR_LOOPBACK                   0x7F000001
296 #define INADDR_BROADCAST         (u_long)(0xFFFFFFFF)
297 #define INADDR_NONE                       0xFFFFFFFF
298
299 struct sockaddr_in
300 { short                  sin_family;
301   u_short                sin_port;
302   struct in_addr         sin_addr;
303   char                   sin_zero[8];
304 };
305
306 #define WSADESCRIPTION_LEN                       256
307 #define WSASYS_STATUS_LEN                        128
308
309 typedef
310 struct WSAData
311 { WORD                   wVersion;
312   WORD                   wHighVersion;
313   char                   szDescription[WSADESCRIPTION_LEN+1];
314   char                   szSystemStatus[WSASYS_STATUS_LEN+1];
315   unsigned short         iMaxSockets;
316   unsigned short         iMaxUdpDg;
317   char                  *lpVendorInfo;
318 } WSADATA, *LPWSADATA;
319
320 #ifndef __INSIDE_MSYS__
321
322 #define IP_OPTIONS                                 1
323 #define SO_DEBUG                                   1
324 #define SO_ACCEPTCONN                              2
325 #define SO_REUSEADDR                               4
326 #define SO_KEEPALIVE                               8
327 #define SO_DONTROUTE                              16
328 #define SO_BROADCAST                              32
329 #define SO_USELOOPBACK                            64
330 #define SO_LINGER                                128
331 #define SO_OOBINLINE                             256
332
333 #define SO_DONTLINGER                    (u_int)(~SO_LINGER)
334
335 #define SO_SNDBUF                             0x1001
336 #define SO_RCVBUF                             0x1002
337 #define SO_SNDLOWAT                           0x1003
338 #define SO_RCVLOWAT                           0x1004
339 #define SO_SNDTIMEO                           0x1005
340 #define SO_RCVTIMEO                           0x1006
341 #define SO_ERROR                              0x1007
342 #define SO_TYPE                               0x1008
343
344 #endif  /* !__INSIDE_MSYS__ */
345
346 /* The following IP defines are specific to WinSock v1.1 (wsock32.dll).
347  * They may cause errors, or produce unexpected results, if exposed when
348  * compiling application code which is intended to use the getsockopts(),
349  * or setsockopts() APIs, as exported from the WinSock v2 system library,
350  * ws2_32.dll.  Please refer to <ws2tcpip.h> for further information.
351  */
352 #define IP_MULTICAST_IF                            2
353 #define IP_MULTICAST_TTL                           3
354 #define IP_MULTICAST_LOOP                          4
355 #define IP_ADD_MEMBERSHIP                          5
356 #define IP_DROP_MEMBERSHIP                         6
357
358 #define IP_DEFAULT_MULTICAST_TTL                   1
359 #define IP_DEFAULT_MULTICAST_LOOP                  1
360 #define IP_MAX_MEMBERSHIPS                        20
361
362 struct ip_mreq
363 { struct in_addr         imr_multiaddr;
364   struct in_addr         imr_interface;
365 };
366
367 #define INVALID_SOCKET                   (SOCKET)(~0)
368 #define SOCKET_ERROR                             (-1)
369 #define SOCK_STREAM                                1
370 #define SOCK_DGRAM                                 2
371 #define SOCK_RAW                                   3
372 #define SOCK_RDM                                   4
373 #define SOCK_SEQPACKET                             5
374 #define TCP_NODELAY                           0x0001
375 #define AF_UNSPEC                                  0
376 #define AF_UNIX                                    1
377 #define AF_INET                                    2
378 #define AF_IMPLINK                                 3
379 #define AF_PUP                                     4
380 #define AF_CHAOS                                   5
381 #define AF_IPX                                     6
382 #define AF_NS                                      6
383 #define AF_ISO                                     7
384
385 #define AF_OSI                                AF_ISO
386
387 #define AF_ECMA                                    8
388 #define AF_DATAKIT                                 9
389 #define AF_CCITT                                  10
390 #define AF_SNA                                    11
391 #define AF_DECnet                                 12
392 #define AF_DLI                                    13
393 #define AF_LAT                                    14
394 #define AF_HYLINK                                 15
395 #define AF_APPLETALK                              16
396 #define AF_NETBIOS                                17
397 #define AF_VOICEVIEW                              18
398 #define AF_FIREFOX                                19
399 #define AF_UNKNOWN1                               20
400 #define AF_BAN                                    21
401 #define AF_ATM                                    22
402 #define AF_INET6                                  23
403
404 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
405
406 #define AF_MAX                                    24
407
408 struct sockaddr
409 { u_short                sa_family;
410   char                   sa_data[14];
411 };
412
413 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
414
415 struct sockproto
416 { u_short                sp_family;
417   u_short                sp_protocol;
418 };
419
420 #define PF_UNSPEC                          AF_UNSPEC
421 #define PF_UNIX                              AF_UNIX
422 #define PF_INET                              AF_INET
423 #define PF_IMPLINK                        AF_IMPLINK
424 #define PF_PUP                                AF_PUP
425 #define PF_CHAOS                            AF_CHAOS
426 #define PF_NS                                  AF_NS
427 #define PF_IPX                                AF_IPX
428 #define PF_ISO                                AF_ISO
429 #define PF_OSI                                AF_OSI
430 #define PF_ECMA                              AF_ECMA
431 #define PF_DATAKIT                        AF_DATAKIT
432 #define PF_CCITT                            AF_CCITT
433 #define PF_SNA                                AF_SNA
434 #define PF_DECnet                          AF_DECnet
435 #define PF_DLI                                AF_DLI
436 #define PF_LAT                                AF_LAT
437 #define PF_HYLINK                          AF_HYLINK
438 #define PF_APPLETALK                    AF_APPLETALK
439 #define PF_VOICEVIEW                    AF_VOICEVIEW
440 #define PF_FIREFOX                        AF_FIREFOX
441 #define PF_UNKNOWN1                      AF_UNKNOWN1
442 #define PF_BAN                                AF_BAN
443 #define PF_ATM                                AF_ATM
444 #define PF_INET6                            AF_INET6
445 #define PF_MAX                                AF_MAX
446
447 #define SOL_SOCKET                            0xFFFF
448 #define SOMAXCONN                                  5
449
450 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
451
452 #define MSG_OOB                                    1
453 #define MSG_PEEK                                   2
454 #define MSG_DONTROUTE                              4
455
456 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
457
458 #define MSG_MAXIOVLEN                             16
459 #define MSG_PARTIAL                           0x8000
460 #define MAXGETHOSTSTRUCT                        1024
461
462 #define FD_READ                                    1
463 #define FD_WRITE                                   2
464 #define FD_OOB                                     4
465 #define FD_ACCEPT                                  8
466 #define FD_CONNECT                                16
467 #define FD_CLOSE                                  32
468
469 #define WSANO_ADDRESS                   WSANO_DATA
470
471 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
472
473 #define h_errno                         WSAGetLastError()
474 #define HOST_NOT_FOUND                  WSAHOST_NOT_FOUND
475 #define TRY_AGAIN                       WSATRY_AGAIN
476 #define NO_RECOVERY                     WSANO_RECOVERY
477 #define NO_DATA                         WSANO_DATA
478 #define NO_ADDRESS                      WSANO_ADDRESS
479
480 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
481
482 WINSOCK_API_LINKAGE SOCKET PASCAL accept (SOCKET, struct sockaddr *, int *);
483
484 WINSOCK_API_LINKAGE int PASCAL bind (SOCKET, const struct sockaddr *, int);
485 WINSOCK_API_LINKAGE int PASCAL closesocket (SOCKET);
486 WINSOCK_API_LINKAGE int PASCAL connect (SOCKET, const struct sockaddr *, int);
487 WINSOCK_API_LINKAGE int PASCAL ioctlsocket (SOCKET, long, u_long *);
488 WINSOCK_API_LINKAGE int PASCAL getpeername (SOCKET, struct sockaddr *, int *);
489 WINSOCK_API_LINKAGE int PASCAL getsockname (SOCKET, struct sockaddr *, int *);
490 WINSOCK_API_LINKAGE int PASCAL getsockopt (SOCKET, int, int, char *, int *);
491
492 WINSOCK_API_LINKAGE unsigned long PASCAL inet_addr (const char *);
493
494 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (char *) inet_ntoa (struct in_addr);
495
496 WINSOCK_API_LINKAGE int PASCAL listen (SOCKET, int);
497 WINSOCK_API_LINKAGE int PASCAL recv (SOCKET, char *, int, int);
498 WINSOCK_API_LINKAGE int PASCAL recvfrom (SOCKET, char *, int, int, struct sockaddr *, int *);
499 WINSOCK_API_LINKAGE int PASCAL send (SOCKET, const char *, int, int);
500 WINSOCK_API_LINKAGE int PASCAL sendto (SOCKET, const char *, int, int, const struct sockaddr *, int);
501 WINSOCK_API_LINKAGE int PASCAL setsockopt (SOCKET, int, int, const char *, int);
502 WINSOCK_API_LINKAGE int PASCAL shutdown (SOCKET, int);
503
504 WINSOCK_API_LINKAGE SOCKET PASCAL socket (int, int, int);
505
506 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct hostent *)  gethostbyaddr (const char *, int, int);
507 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct hostent *)  gethostbyname (const char *);
508 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct servent *)  getservbyport (int, const char *);
509 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct servent *)  getservbyname (const char *, const char *);
510 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct protoent *) getprotobynumber (int);
511 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct protoent *) getprotobyname (const char *);
512
513 WINSOCK_API_LINKAGE int PASCAL WSAStartup (WORD, LPWSADATA);
514 WINSOCK_API_LINKAGE int PASCAL WSACleanup (void);
515 WINSOCK_API_LINKAGE void PASCAL WSASetLastError (int);
516 WINSOCK_API_LINKAGE int PASCAL WSAGetLastError (void);
517
518 WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void);
519 WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void);
520 WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC);
521 WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void);
522
523 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByName (HWND, u_int, const char *, const char *, char *, int);
524 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByPort (HWND, u_int, int, const char *, char *, int);
525 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetProtoByName (HWND, u_int, const char *, char *, int);
526 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetProtoByNumber (HWND, u_int, int, char *, int);
527 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetHostByName (HWND, u_int, const char *, char *, int);
528 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetHostByAddr (HWND, u_int, const char *, int, int, char *, int);
529
530 WINSOCK_API_LINKAGE int PASCAL WSACancelAsyncRequest (HANDLE);
531 WINSOCK_API_LINKAGE int PASCAL WSAAsyncSelect (SOCKET, HWND, u_int, long);
532
533 #if ! (defined __INSIDE_CYGWIN__ || defined __INSIDE_MSYS__)
534
535 WINSOCK_API_LINKAGE u_long PASCAL htonl (u_long);
536 WINSOCK_API_LINKAGE u_long PASCAL ntohl (u_long);
537 WINSOCK_API_LINKAGE u_short PASCAL htons (u_short);
538 WINSOCK_API_LINKAGE u_short PASCAL ntohs (u_short);
539 WINSOCK_API_LINKAGE int PASCAL select (int nfds, fd_set *, fd_set *, fd_set *, const struct timeval *);
540 int PASCAL gethostname (char *, int );
541
542 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
543
544 #define WSAMAKEASYNCREPLY(b,e)                  MAKELONG(b,e)
545 #define WSAMAKESELECTREPLY(e,error)             MAKELONG(e,error)
546 #define WSAGETASYNCBUFLEN(l)                    LOWORD(l)
547 #define WSAGETASYNCERROR(l)                     HIWORD(l)
548 #define WSAGETSELECTEVENT(l)                    LOWORD(l)
549 #define WSAGETSELECTERROR(l)                    HIWORD(l)
550
551 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
552 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
553 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
554 typedef struct linger LINGER, *PLINGER, *LPLINGER;
555 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
556 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
557 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
558 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
559 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
560
561 _END_C_DECLS
562
563 /* MSDN documentation indicates that the MS-specific extensions exported
564  * from mswsock.dll, (i.e. the AcceptEx(), TransmitFile(), WSARecEx(), and
565  * GetAcceptExSockaddrs() functions), are declared in <mswsock.h>.  These
566  * extensions are not supported on Win9x or WinCE.  However, WinSock v1.1
567  * dependent code may expect that the declarations and associated defines
568  * will be in this header; thus we include <mswsock.h> here.
569  *
570  * When linking against the WinSock v1.1 library, wsock32.dll, the mswsock
571  * functions are automatically routed to mswsock.dll (on platforms which
572  * support it).  The WinSock v2 library, ws2_32.dll, does not contain any
573  * references to the mswsock extensions.
574  */
575 #include <mswsock.h>
576
577 #undef  __WINSOCK_H_SOURCED__
578 #endif  /* _WINSOCK_H: $RCSfile$: end of file */