OSDN Git Service

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