4 * Definitions for WinSock Version 1.1 API; also includes a subset of the
5 * definitions which become applicable for WinSock Version 2, filtered such
6 * that they are exposed only when this file is included by <winsock2.h>
11 * Adaptation by Anders Norlander <anorland@hem2.passagen.se>
12 * Copyright (C) 1998-2004, 2012, 2016, 2017, 2019, MinGW.org Project.
14 * Portions Copyright (C) 1980, 1983, 1988, 1993
15 * The Regents of the University of California. All rights reserved.
17 * Portions Copyright (C) 1993 by Digital Equipment Corporation.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
23 * 1. Redistributions of source code must retain the above copyright
24 * notices, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * 3. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 #pragma GCC system_header
48 #ifdef __USE_MINGW_WINSOCK_DEFAULT
49 /* This is default inclusion of <winsock.h> by <windows.h>, (or some other
50 * W32API header; there is no sane reason for __USE_MINGW_WINSOCK_DEFAULT to
51 * have been defined, otherwise). Whereas Microsoft would simply default to
52 * using WinSock v1.1, MinGW may choose an alternative default.
54 #include <sdkddkver.h>
55 #if _WIN32_WINNT >= _WIN32_WINNT_NT4
56 /* When the target operating system is WinNT4, or later, we prefer to support
57 * the WinSock v2 API, by default; (this is consistent with the default choice
58 * which was traditionally specified within MinGW.org's <windows.h>).
62 #endif /* __USE_MINGW_WINSOCK_DEFAULT for Win-NT4 and later */
63 #endif /* __USE_MINGW_WINSOCK_DEFAULT (any Windows version) */
65 /* If "winsock2.h" was included, to satisfy the __USE_MINGW_WINSOCK_DEFAULT
66 * condition, then the remainder of this file has already been processed, due
67 * to reinclusion by "winsock2.h"; test _WINSOCK_H again to prevent redundant
68 * reprocessing, (which may be potentially harmful)...
71 /* ...but, when _WINSOCK_H hasn't been defined yet, then this is our first
72 * opportunity to process this <winsock.h> content; activate the guard, and
73 * proceed to process it now.
76 #define _GNU_H_WINDOWS32_SOCKETS
77 #define __WINSOCK_H_SOURCED__ 1
81 #include <sys/bsdtypes.h>
84 #ifndef WINSOCK_API_LINKAGE
85 /* Historically, this was defined (and used) within <winsock2.h>, but not
86 * <winsock.h>, to qualify function declarations which are common to both;
87 * for consistency, we now define, (and subsequently use it here), while
88 * preserving the effect of its previous absence, within <winsock.h>, by
89 * ensuring that it expands to nothing in this context.
91 * FIXME: Is this logical? Perhaps <winsock.h> should adopt the effect,
92 * exactly as it was previously implemented exclusively in <winsock2.h>?
94 #if defined _WINSOCK2_H && defined __W32API_USE_DLLIMPORT__
95 /* To preserve backward compatibility, DECLSPEC_IMPORT option is
96 * available only to WinSock v2 clients, which request it...
98 #define WINSOCK_API_LINKAGE DECLSPEC_IMPORT
101 /* ...whereas WinSock v1.1 clients, and those WinSock v2 clients which
102 * do not request DECLSPEC_IMPORT, will always use default linkage.
104 #define WINSOCK_API_LINKAGE
108 #if ! defined _USE_SYS_TYPES_FD_SET && defined USE_SYS_TYPES_FD_SET
109 /* Originally defined by the deprecated name, USE_SYS_TYPES_FD_SET, users
110 * may specify this to suppress warnings, in the event that (incompatible)
111 * fd_set manipulation macros may have been inherited from <sys/types.h>;
112 * accommodate use of the deprecated feature test name.
114 #warning "Feature test macro USE_SYS_TYPES_FD_SET is deprecated."
115 #warning "Use the _USE_SYS_TYPES_FD_SET feature test macro instead."
116 #define _USE_SYS_TYPES_FD_SET 1
119 #ifndef __WINSOCK2_DEPRECATED
120 /* Some of the WinSock v1.1 declarations have become deprecated in
121 * WinSock v2. If <winsock2.h> has been included, this deprecation
122 * attribute macro should already have been defined; if not, we now
123 * define it to do nothing.
125 #define __WINSOCK2_DEPRECATED
130 typedef u_int SOCKET;
133 #define FD_SETSIZE 64
136 /* shutdown() how types */
137 #define SD_RECEIVE 0x00
141 #ifndef _SYS_TYPES_FD_SET
142 /* fd_set may have been defined by the newlib <sys/types.h>, if the
143 * internal __USE_W32_SOCKETS feature test has not been enabled.
149 SOCKET fd_array[FD_SETSIZE];
153 int FD_ISSET (SOCKET, fd_set *);
154 #define FD_ISSET( __fd, __set ) __FD_ISSET ((__fd), (__set))
156 /* Microsoft provide this library function equivalent of the FD_ISSET
157 * macro, and erroneously claim that it is neccessary to implement the
158 * macro. We could just as easily implement it entirely inline...
160 int PASCAL __WSAFDIsSet (SOCKET, fd_set *);
161 /* ...but, given the availability of the library function, we may just
164 __CRT_ALIAS int __FD_ISSET( SOCKET __fd, fd_set *__set )
165 { return __WSAFDIsSet (__fd, __set); }
166 #endif /* ! defined FD_ISSET */
169 #if !_WINSOCK_ANOMALOUS_TYPEDEFS
170 /* WinSock is intended to mimic the Berkeley Sockets API, for which
171 * POSIX.1 provides a reference specification; this states that FD_SET
172 * may be implemented as either a macro, or as a function. The reference
173 * <winsock.h> implementation at http://www.sockets.com/winsock.htm#WinsockH
174 * includes a typedef for FD_SET, which a) conflicts with the latter POSIX.1
175 * provision, and b) creates potential confusion with the former. Thus, we
176 * prefer to conform with POSIX.1 functional semantics, and recommend that
177 * users avoid the potentially confusing FD_SET typedefs, so allowing us
178 * to provide this function prototype:
180 void FD_SET (SOCKET, fd_set *);
182 #else /* _WINSOCK_ANOMALOUS_TYPEDEFS */
183 /* However, for users who insist on eschewing standard C/C++ syntax, and
184 * for whatever reason must use FD_SET as a data type, instead of correctly
185 * referring to fd_set, or for pointer references, use PFD_SET or LPFD_SET
186 * instead of standard fd_set * references, we make these anomalous types
187 * visible, when the _WINSOCK_ANOMALOUS_TYPEDEFS feature test macro is
188 * defined with a non-zero value.
190 #warning "FD_SET, PFD_SET, and LPFD_SET data types are non-portable."
191 #warning "Use portable fd_set, and fd_set * type references instead."
193 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
195 #define FD_SET( __fd, __set ) __FD_SET ((__fd), (__set))
196 __CRT_ALIAS void __FD_SET (SOCKET __fd, fd_set *__set)
197 { if( (__set->fd_count < FD_SETSIZE) && ! FD_ISSET (__fd, __set) )
198 __set->fd_array[__set->fd_count++] = __fd;
200 #endif /* ! defined FD_SET */
203 void FD_CLR (SOCKET, fd_set *);
204 #define FD_CLR( __fd, __set ) __FD_CLR ((__fd), (__set))
205 __CRT_ALIAS void __FD_CLR (SOCKET __fd, fd_set *__set)
206 { u_int __m, __n; for (__m = __n = 0; __n < __set->fd_count; __n++)
207 { if (__fd != __set->fd_array[__n])
208 { if (__m < __n) __set->fd_array[__m] = __set->fd_array[__n];
211 } __set->fd_count = __m;
213 #endif /* ! defined FD_CLR */
216 void FD_ZERO (fd_set *);
217 #define FD_ZERO( __set ) __FD_ZERO (__set)
218 __CRT_ALIAS void __FD_ZERO (fd_set *__set)
219 { __set->fd_count = 0; }
220 #endif /* ! defined FD_ZERO */
222 #elif ! defined _USE_SYS_TYPES_FD_SET
223 /* Definitions from <sys/types.h> probably aren't what the user wants;
224 * if they know what they are doing, and they are sure that this really
225 * is what they want, then they may enable the _USE_SYS_TYPES_FD_SET
226 * feature test macro, to suppress this warning.
228 #warning "fd_set and associated macros have been defined in <sys/types.h>"
229 #warning "Your <sys/types.h> may cause runtime problems with W32 sockets."
230 #endif /* !_SYS_TYPES_FD_SET */
232 #ifndef __INSIDE_MSYS__
239 # define h_addr h_addr_list[0]
248 #endif /* !__INSIDE_MSYS__ */
250 #define IOCPARM_MASK 0x7F
251 #define IOC_VOID 0x20000000
252 #define IOC_OUT 0x40000000
253 #define IOC_IN 0x80000000
254 #define IOC_INOUT (IOC_IN | IOC_OUT)
256 #ifndef __INSIDE_MSYS__
258 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
259 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
260 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
262 #define FIONBIO _IOW('f', 126, u_long)
264 #endif /* !__INSIDE_MSYS__ */
266 #define FIONREAD _IOR('f', 127, u_long)
267 #define FIOASYNC _IOW('f', 125, u_long)
268 #define SIOCSHIWAT _IOW('s', 0, u_long)
269 #define SIOCGHIWAT _IOR('s', 1, u_long)
270 #define SIOCSLOWAT _IOW('s', 2, u_long)
271 #define SIOCGLOWAT _IOR('s', 3, u_long)
272 #define SIOCATMARK _IOR('s', 7, u_long)
274 #ifndef __INSIDE_MSYS__
296 #endif /* !__INSIDE_MSYS__ */
299 #define IPPROTO_ICMP 1
300 #define IPPROTO_IGMP 2
301 #define IPPROTO_GGP 3
302 #define IPPROTO_TCP 6
303 #define IPPROTO_PUP 12
304 #define IPPROTO_UDP 17
305 #define IPPROTO_IDP 22
306 #define IPPROTO_ND 77
308 #define IPPROTO_RAW 255
309 #define IPPROTO_MAX 256
311 #define IPPORT_ECHO 7
312 #define IPPORT_DISCARD 9
313 #define IPPORT_SYSTAT 11
314 #define IPPORT_DAYTIME 13
315 #define IPPORT_NETSTAT 15
316 #define IPPORT_FTP 21
317 #define IPPORT_TELNET 23
318 #define IPPORT_SMTP 25
319 #define IPPORT_TIMESERVER 37
320 #define IPPORT_NAMESERVER 42
321 #define IPPORT_WHOIS 43
322 #define IPPORT_MTP 57
323 #define IPPORT_TFTP 69
324 #define IPPORT_RJE 77
325 #define IPPORT_FINGER 79
326 #define IPPORT_TTYLINK 87
327 #define IPPORT_SUPDUP 95
328 #define IPPORT_EXECSERVER 512
329 #define IPPORT_LOGINSERVER 513
330 #define IPPORT_CMDSERVER 514
331 #define IPPORT_EFSSERVER 520
332 #define IPPORT_BIFFUDP 512
333 #define IPPORT_WHOSERVER 513
334 #define IPPORT_ROUTESERVER 520
335 #define IPPORT_RESERVED 1024
337 #define IMPLINK_IP 155
338 #define IMPLINK_LOWEXPER 156
339 #define IMPLINK_HIGHEXPER 158
342 #define s_addr S_un.S_addr
343 #define s_host S_un.S_un_b.s_b2
344 #define s_net S_un.S_un_b.s_b1
345 #define s_imp S_un.S_un_w.s_w2
346 #define s_impno S_un.S_un_b.s_b4
347 #define s_lh S_un.S_un_b.s_b3
349 { struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
350 struct { u_short s_w1,s_w2; } S_un_w;
355 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
356 #define IN_CLASSA_NET 0xFF000000
357 #define IN_CLASSA_NSHIFT 24
358 #define IN_CLASSA_HOST 0x00FFFFFF
359 #define IN_CLASSA_MAX 128
360 #define IN_CLASSB(i) (((long)(i) & 0xC0000000) == 0x80000000)
361 #define IN_CLASSB_NET 0xFFFF0000
362 #define IN_CLASSB_NSHIFT 16
363 #define IN_CLASSB_HOST 0x0000FFFF
364 #define IN_CLASSB_MAX 65536
365 #define IN_CLASSC(i) (((long)(i) & 0xE0000000) == 0xC0000000)
366 #define IN_CLASSC_NET 0xFFFFFF00
367 #define IN_CLASSC_NSHIFT 8
368 #define IN_CLASSC_HOST 0xFF
369 #define INADDR_ANY (u_long)(0)
370 #define INADDR_LOOPBACK 0x7F000001
371 #define INADDR_BROADCAST (u_long)(0xFFFFFFFF)
372 #define INADDR_NONE 0xFFFFFFFF
377 struct in_addr sin_addr;
381 #define WSADESCRIPTION_LEN 256
382 #define WSASYS_STATUS_LEN 128
388 char szDescription[WSADESCRIPTION_LEN+1];
389 char szSystemStatus[WSASYS_STATUS_LEN+1];
390 unsigned short iMaxSockets;
391 unsigned short iMaxUdpDg;
393 } WSADATA, *LPWSADATA;
395 #ifndef __INSIDE_MSYS__
399 #define SO_ACCEPTCONN 2
400 #define SO_REUSEADDR 4
401 #define SO_KEEPALIVE 8
402 #define SO_DONTROUTE 16
403 #define SO_BROADCAST 32
404 #define SO_USELOOPBACK 64
405 #define SO_LINGER 128
406 #define SO_OOBINLINE 256
408 #define SO_DONTLINGER (u_int)(~SO_LINGER)
410 #define SO_SNDBUF 0x1001
411 #define SO_RCVBUF 0x1002
412 #define SO_SNDLOWAT 0x1003
413 #define SO_RCVLOWAT 0x1004
414 #define SO_SNDTIMEO 0x1005
415 #define SO_RCVTIMEO 0x1006
416 #define SO_ERROR 0x1007
417 #define SO_TYPE 0x1008
419 #endif /* !__INSIDE_MSYS__ */
422 /* The following IP defines are specific to WinSock v1.1 (wsock32.dll).
423 * They may cause errors, or produce unexpected results, if exposed when
424 * compiling application code which is intended to use the getsockopts(),
425 * or setsockopts() APIs, as exported from the WinSock v2 system library,
426 * ws2_32.dll. Please refer to <ws2tcpip.h> for further information.
428 #define IP_MULTICAST_IF 2
429 #define IP_MULTICAST_TTL 3
430 #define IP_MULTICAST_LOOP 4
431 #define IP_ADD_MEMBERSHIP 5
432 #define IP_DROP_MEMBERSHIP 6
434 #define IP_DEFAULT_MULTICAST_TTL 1
435 #define IP_DEFAULT_MULTICAST_LOOP 1
436 #define IP_MAX_MEMBERSHIPS 20
439 { struct in_addr imr_multiaddr;
440 struct in_addr imr_interface;
442 #endif /* !_WINSOCK2_H */
444 #define INVALID_SOCKET (SOCKET)(~0)
445 #define SOCKET_ERROR (-1)
446 #define SOCK_STREAM 1
450 #define SOCK_SEQPACKET 5
451 #define TCP_NODELAY 0x0001
462 #define AF_OSI AF_ISO
472 #define AF_APPLETALK 16
473 #define AF_NETBIOS 17
474 #define AF_VOICEVIEW 18
475 #define AF_FIREFOX 19
476 #define AF_UNKNOWN1 20
481 #ifndef __INSIDE_MSYS__
490 #endif /* !__INSIDE_MSYS__ */
497 #define PF_UNSPEC AF_UNSPEC
498 #define PF_UNIX AF_UNIX
499 #define PF_INET AF_INET
500 #define PF_IMPLINK AF_IMPLINK
501 #define PF_PUP AF_PUP
502 #define PF_CHAOS AF_CHAOS
504 #define PF_IPX AF_IPX
505 #define PF_ISO AF_ISO
506 #define PF_OSI AF_OSI
507 #define PF_ECMA AF_ECMA
508 #define PF_DATAKIT AF_DATAKIT
509 #define PF_CCITT AF_CCITT
510 #define PF_SNA AF_SNA
511 #define PF_DECnet AF_DECnet
512 #define PF_DLI AF_DLI
513 #define PF_LAT AF_LAT
514 #define PF_HYLINK AF_HYLINK
515 #define PF_APPLETALK AF_APPLETALK
516 #define PF_VOICEVIEW AF_VOICEVIEW
517 #define PF_FIREFOX AF_FIREFOX
518 #define PF_UNKNOWN1 AF_UNKNOWN1
519 #define PF_BAN AF_BAN
520 #define PF_ATM AF_ATM
521 #define PF_INET6 AF_INET6
522 #define PF_MAX AF_MAX
524 #define SOL_SOCKET 0xFFFF
526 #ifndef __INSIDE_MSYS__
528 /* This definition of SOMAXCONN is correct for WinSock v1.1, but not
529 * for WinSock v2; we define it thus here, but note that, if included
530 * by <winsock2.h>, it will subsequently be overridden by the correct
531 * WinSock v2 definition.
537 #define MSG_DONTROUTE 4
539 #endif /* !__INSIDE_MSYS__ */
541 #define MSG_MAXIOVLEN 16
542 #define MSG_PARTIAL 0x8000
543 #define MAXGETHOSTSTRUCT 1024
546 { /* Enumerate the flags used to represent the events which may be
547 * detected on any socket, when monitored via an fd_set array.
550 # define FD_READ (1 << FD_READ_BIT)
553 # define FD_WRITE (1 << FD_WRITE_BIT)
556 # define FD_OOB (1 << FD_OOB_BIT)
559 # define FD_ACCEPT (1 << FD_ACCEPT_BIT)
562 # define FD_CONNECT (1 << FD_CONNECT_BIT)
565 # define FD_CLOSE (1 << FD_CLOSE_BIT)
568 /* WinSock v1.1 defines no further events, beyond FD_CLOSE (1 << 5 = 32).
569 * The following are specific to WinSock v2; for convenience, they may be
570 * enumerated here, but they are exposed only when <winsock.h> is included
571 * indirectly, by way of including <winsock2.h>
574 # define FD_QOS (1 << FD_QOS_BIT)
577 # define FD_GROUP_QOS (1 << FD_GROUP_QOS_BIT)
579 FD_ROUTING_INTERFACE_CHANGE_BIT,
580 # define FD_ROUTING_INTERFACE_CHANGE (1 << FD_ROUTING_INTERFACE_CHANGE_BIT)
582 FD_ADDRESS_LIST_CHANGE_BIT,
583 # define FD_ADDRESS_LIST_CHANGE (1 << FD_ADDRESS_LIST_CHANGE_BIT)
585 # endif /* _WINSOCK2_H */
586 /* Regardless of WinSock version, FD_MAX_EVENTS represents the first
587 * unused flag bit, whence we may deduce FD_ALL_EVENTS, as a mask for
588 * all supported event flags, specific to the WinSock version in use.
591 # define FD_ALL_EVENTS ((1 << FD_MAX_EVENTS) - 1)
594 #define WSANO_ADDRESS WSANO_DATA
596 #ifndef __INSIDE_MSYS__
598 #define h_errno WSAGetLastError()
599 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
600 #define TRY_AGAIN WSATRY_AGAIN
601 #define NO_RECOVERY WSANO_RECOVERY
602 #define NO_DATA WSANO_DATA
603 #define NO_ADDRESS WSANO_ADDRESS
605 #endif /* !__INSIDE_MSYS__ */
607 WINSOCK_API_LINKAGE SOCKET PASCAL accept (SOCKET, struct sockaddr *, int *);
609 WINSOCK_API_LINKAGE int PASCAL bind (SOCKET, const struct sockaddr *, int);
610 WINSOCK_API_LINKAGE int PASCAL closesocket (SOCKET);
611 WINSOCK_API_LINKAGE int PASCAL connect (SOCKET, const struct sockaddr *, int);
612 WINSOCK_API_LINKAGE int PASCAL ioctlsocket (SOCKET, long, u_long *);
613 WINSOCK_API_LINKAGE int PASCAL getpeername (SOCKET, struct sockaddr *, int *);
614 WINSOCK_API_LINKAGE int PASCAL getsockname (SOCKET, struct sockaddr *, int *);
615 WINSOCK_API_LINKAGE int PASCAL getsockopt (SOCKET, int, int, char *, int *);
617 WINSOCK_API_LINKAGE unsigned long PASCAL inet_addr (const char *);
619 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (char *) inet_ntoa (struct in_addr);
621 WINSOCK_API_LINKAGE int PASCAL listen (SOCKET, int);
622 WINSOCK_API_LINKAGE int PASCAL recv (SOCKET, char *, int, int);
623 WINSOCK_API_LINKAGE int PASCAL recvfrom (SOCKET, char *, int, int, struct sockaddr *, int *);
624 WINSOCK_API_LINKAGE int PASCAL send (SOCKET, const char *, int, int);
625 WINSOCK_API_LINKAGE int PASCAL sendto (SOCKET, const char *, int, int, const struct sockaddr *, int);
626 WINSOCK_API_LINKAGE int PASCAL setsockopt (SOCKET, int, int, const char *, int);
627 WINSOCK_API_LINKAGE int PASCAL shutdown (SOCKET, int);
629 WINSOCK_API_LINKAGE SOCKET PASCAL socket (int, int, int);
631 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct hostent *) gethostbyaddr (const char *, int, int);
632 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct hostent *) gethostbyname (const char *);
633 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct servent *) getservbyport (int, const char *);
634 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct servent *) getservbyname (const char *, const char *);
635 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct protoent *) getprotobynumber (int);
636 WINSOCK_API_LINKAGE DECLARE_STDCALL_P (struct protoent *) getprotobyname (const char *);
638 WINSOCK_API_LINKAGE int PASCAL WSAStartup (WORD, LPWSADATA);
639 WINSOCK_API_LINKAGE int PASCAL WSACleanup (void);
640 WINSOCK_API_LINKAGE void PASCAL WSASetLastError (int);
641 WINSOCK_API_LINKAGE int PASCAL WSAGetLastError (void);
643 /* The following four pseudo-blocking functions are provided
644 * to support WinSock v1.1, but have been marked as deprecated
645 * in WinSock v2; they remain available, but it is recommended
646 * that threads should be used instead!
648 WINSOCK_API_LINKAGE BOOL PASCAL WSAIsBlocking (void) __WINSOCK2_DEPRECATED;
649 WINSOCK_API_LINKAGE int PASCAL WSAUnhookBlockingHook (void) __WINSOCK2_DEPRECATED;
650 WINSOCK_API_LINKAGE FARPROC PASCAL WSASetBlockingHook (FARPROC) __WINSOCK2_DEPRECATED;
651 WINSOCK_API_LINKAGE int PASCAL WSACancelBlockingCall (void) __WINSOCK2_DEPRECATED;
653 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByName (HWND, u_int, const char *, const char *, char *, int);
654 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetServByPort (HWND, u_int, int, const char *, char *, int);
655 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetProtoByName (HWND, u_int, const char *, char *, int);
656 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetProtoByNumber (HWND, u_int, int, char *, int);
657 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetHostByName (HWND, u_int, const char *, char *, int);
658 WINSOCK_API_LINKAGE HANDLE PASCAL WSAAsyncGetHostByAddr (HWND, u_int, const char *, int, int, char *, int);
660 WINSOCK_API_LINKAGE int PASCAL WSACancelAsyncRequest (HANDLE);
661 WINSOCK_API_LINKAGE int PASCAL WSAAsyncSelect (SOCKET, HWND, u_int, long);
663 #ifndef __INSIDE_MSYS__
665 WINSOCK_API_LINKAGE u_long PASCAL htonl (u_long);
666 WINSOCK_API_LINKAGE u_long PASCAL ntohl (u_long);
667 WINSOCK_API_LINKAGE u_short PASCAL htons (u_short);
668 WINSOCK_API_LINKAGE u_short PASCAL ntohs (u_short);
669 WINSOCK_API_LINKAGE int PASCAL select (int nfds, fd_set *, fd_set *, fd_set *, const struct timeval *);
671 #endif /* !__INSIDE_MSYS__ */
673 WINSOCK_API_LINKAGE int PASCAL gethostname (char *, int);
675 #define WSAMAKEASYNCREPLY(b,e) MAKELONG(b,e)
676 #define WSAMAKESELECTREPLY(e,error) MAKELONG(e,error)
677 #define WSAGETASYNCBUFLEN(l) LOWORD(l)
678 #define WSAGETASYNCERROR(l) HIWORD(l)
679 #define WSAGETSELECTEVENT(l) LOWORD(l)
680 #define WSAGETSELECTERROR(l) HIWORD(l)
682 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
683 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
684 typedef struct linger LINGER, *PLINGER, *LPLINGER;
685 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
686 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
687 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
688 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
689 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
694 /* MSDN documentation indicates that the MS-specific extensions exported
695 * from mswsock.dll, (i.e. the AcceptEx(), TransmitFile(), WSARecEx(), and
696 * GetAcceptExSockaddrs() functions), are declared in <mswsock.h>. These
697 * extensions are not supported on Win9x or WinCE. However, WinSock v1.1
698 * dependent code may expect that the declarations and associated defines
699 * will be in this header; thus we include <mswsock.h> here.
701 * When linking against the WinSock v1.1 library, wsock32.dll, the mswsock
702 * functions are automatically routed to mswsock.dll (on platforms which
703 * support it). The WinSock v2 library, ws2_32.dll, does not contain any
704 * references to the mswsock extensions.
708 #endif /* !_WINSOCK2_H */
709 #endif /* !_WINSOCK_H redundancy check */
711 #undef __WINSOCK_H_SOURCED__
712 #endif /* _WINSOCK_H: $RCSfile$: end of file */