4 Windows Sockets specification version 1.1
6 Copyright (C) 1996 Free Software Foundation, Inc.
7 Thanks to Linux header files for supplying many needed definitions
9 Author: Scott Christley <scottc@net-community.com>
12 This file is part of the Windows32 API Library.
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Library General Public
16 License as published by the Free Software Foundation; either
17 version 2 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Library General Public License for more details.
24 If you are interested in a warranty or support for this source code,
25 contact Scott Christley <scottc@net-community.com> for more information.
27 You should have received a copy of the GNU Library General Public
28 License along with this library; see the file COPYING.LIB.
29 If not, write to the Free Software Foundation,
30 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 * Portions Copyright (c) 1980, 1983, 1988, 1993
35 * The Regents of the University of California. All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
68 * Permission to use, copy, modify and distribute this software for any
69 * purpose with or without fee is hereby granted, provided that the above
70 * copyright notice and this permission notice appear in all copies, and that
71 * the name of Digital Equipment Corporation not be used in advertising or
72 * publicity pertaining to distribution of the document or software without
73 * specific, written prior permission.
75 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
76 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
77 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
78 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
79 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
80 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
81 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
87 #ifndef _GNU_H_WINDOWS32_SOCKETS
88 #define _GNU_H_WINDOWS32_SOCKETS
92 #endif /* __cplusplus */
96 typedef unsigned char u_char;
97 typedef unsigned short u_short;
98 typedef unsigned int u_int;
99 typedef unsigned long u_long;
103 Default maximium number of sockets.
104 Define this before including Sockets.h to increase; this does not
105 mean that the underlying Windows Sockets implementation has to
109 #define FD_SETSIZE 64
110 #endif /* !FD_SETSIZE */
113 These macros are critical to the usage of Windows Sockets.
114 According to the documentation, a SOCKET is no longer represented
115 by a "small non-negative integer"; so all programs MUST use these
116 macros for setting, initializing, clearing and checking the
120 typedef u_int SOCKET;
122 /* fd_set may have been defined by the newlib <sys/types.h>. */
126 typedef struct fd_set {
128 SOCKET fd_array[FD_SETSIZE];
131 /* Internal function, not documented except in winsock.h */
132 extern int PASCAL __WSAFDIsSet(SOCKET, fd_set*);
137 #define FD_CLR(fd, set) do { \
139 for (__i = 0; __i < ((fd_set*)(set))->fd_count ; __i++) { \
140 if (((fd_set*)(set))->fd_array[__i] == fd) { \
141 while (__i < ((fd_set*)(set))->fd_count-1) { \
142 ((fd_set*)(set))->fd_array[__i] = \
143 ((fd_set*)(set))->fd_array[__i+1]; \
146 ((fd_set*)(set))->fd_count--; \
155 #define FD_SET(fd, set) do { \
156 if (((fd_set*)(set))->fd_count < FD_SETSIZE) \
157 ((fd_set*)(set))->fd_array[((fd_set*)(set))->fd_count++]=(fd);\
163 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
168 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
174 long tv_sec; /* seconds */
175 long tv_usec; /* microseconds */
178 int tz_minuteswest; /* minutes west of Greenwich */
179 int tz_dsttime; /* type of dst correction */
183 Operations on timevals.
185 NB: timercmp does not work for >= or <=.
187 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
188 #define timercmp(tvp, uvp, cmp) \
189 (((tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) \
190 || (tvp)->tv_sec cmp (uvp)->tv_sec)
191 #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
194 ioctl command encoding.
195 Some of this is different than what Linux has
197 #define IOCPARM_MASK 0x7f
198 #define IOC_VOID 0x20000000
199 #define IOC_OUT 0x40000000
200 #define IOC_IN 0x80000000
201 #define IOC_INOUT (IOC_IN | IOC_OUT)
203 /* _IO(magic, subcode) */
204 #define _IO(c,d) (IOC_VOID | ((c)<<8) | (d))
205 /* _IOXX(magic, subcode, arg_t) */
206 #define _IOW(c,d,t) (IOC_IN | (((long)sizeof(t) & IOCPARM_MASK)<<16) | \
208 #define _IOR(c,d,t) (IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK)<<16) | \
212 This stuff is hard-coded on Linux
213 But winsock.h uses the macros defined above
215 #define FIONREAD _IOR('f', 127, u_long)
216 #define FIONBIO _IOW('f', 126, u_long)
217 #define FIOASYNC _IOW('f', 125, u_long)
219 #define SIOCSHIWAT _IOW('s', 0, u_long)
220 #define SIOCGHIWAT _IOR('s', 1, u_long)
221 #define SIOCSLOWAT _IOW('s', 2, u_long)
222 #define SIOCGLOWAT _IOR('s', 3, u_long)
223 #define SIOCATMARK _IOR('s', 7, u_long)
226 Structures returned by network data base library, taken from the
227 BSD file netdb.h. All addresses are supplied in host order, and
228 returned in network order (suitable for use in system calls).
230 Slight modifications for differences between Linux and winsock.h
234 char *h_name; /* official name of host */
235 char **h_aliases; /* alias list */
236 short h_addrtype; /* host address type */
237 short h_length; /* length of address */
238 char **h_addr_list; /* list of addresses */
239 #define h_addr h_addr_list[0] /* address, for backward compat */
243 * Assumption here is that a network number
244 * fits in an unsigned long -- someday that won't be true!
247 char *n_name; /* official name of net */
248 char **n_aliases; /* alias list */
249 short n_addrtype; /* net address type */
250 u_long n_net; /* network # */
254 char *s_name; /* official service name */
255 char **s_aliases; /* alias list */
256 short s_port; /* port # */
257 char *s_proto; /* protocol to use */
261 char *p_name; /* official protocol name */
262 char **p_aliases; /* alias list */
263 short p_proto; /* protocol # */
267 Standard well-known IP protocols.
268 For some reason there are differences between Linx and winsock.h
273 IPPROTO_GGP = 2, /* huh? */
275 IPPROTO_TCP = 6, /* Transmission Control Protocol */
278 IPPROTO_UDP = 17, /* User Datagram Protocol */
280 IPPROTO_ND = 77, /* This one was in winsock.h */
282 IPPROTO_RAW = 255, /* raw IP packets */
286 /* Standard well-known ports */
296 IPPORT_TIMESERVER = 37,
297 IPPORT_NAMESERVER = 42,
307 IPPORT_EXECSERVER = 512,
308 IPPORT_LOGINSERVER = 513,
309 IPPORT_CMDSERVER = 514,
310 IPPORT_EFSSERVER = 520,
313 IPPORT_BIFFUDP = 512,
314 IPPORT_WHOSERVER = 513,
315 IPPORT_ROUTESERVER = 520,
317 /* Ports less than this value are reservered for privileged processes. */
318 IPPORT_RESERVED = 1024,
320 /* Ports greater than this value are reserved for
321 (non-privileged) processes */
322 IPPORT_USERRESERVED = 5000
326 #define IMPLINK_IP 155
327 #define IMPLINK_LOWEXPER 156
328 #define IMPLINK_HIGHEXPER 158
330 /* Linux uses a simple unsigned long int, but winsock.h ... */
333 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
334 struct { u_short s_w1,s_w2; } S_un_w;
337 #define s_addr S_un.S_addr
338 #define s_host S_un.S_un_b.s_b2
339 #define s_net S_un.S_un_b.s_b1
340 #define s_imp S_un.S_un_w.s_w2
341 #define s_impno S_un.S_un_b.s_b4
342 #define s_lh S_un.S_un_b.s_b3
346 Definitions of bits in internet address integers.
347 On subnets, host and network parts are found according
348 to the subnet mask, not these masks.
350 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
351 #define IN_CLASSA_NET 0xff000000
352 #define IN_CLASSA_NSHIFT 24
353 #define IN_CLASSA_HOST 0x00ffffff
354 #define IN_CLASSA_MAX 128
356 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
357 #define IN_CLASSB_NET 0xffff0000
358 #define IN_CLASSB_NSHIFT 16
359 #define IN_CLASSB_HOST 0x0000ffff
360 #define IN_CLASSB_MAX 65536
362 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
363 #define IN_CLASSC_NET 0xffffff00
364 #define IN_CLASSC_NSHIFT 8
365 #define IN_CLASSC_HOST 0x000000ff
367 #define INADDR_ANY (u_long)0x00000000
368 #define INADDR_LOOPBACK 0x7f000001
369 #define INADDR_BROADCAST (u_long)0xffffffff
370 #define INADDR_NONE 0xffffffff
373 Structure describing an Internet (IP) socket address.
378 struct in_addr sin_addr;
383 EVERYTHING FROM THIS POINT IS MAINLY SPECIFIC TO Win32
385 Structure which holds the detail for the underlying Window Sockets
386 implementation. Set when WSAStartup() is called.
388 #define WSADESCRIPTION_LEN 256
389 #define WSASYS_STATUS_LEN 128
391 typedef struct WSAData {
394 char szDescription[WSADESCRIPTION_LEN+1];
395 char szSystemStatus[WSASYS_STATUS_LEN+1];
396 unsigned short iMaxSockets;
397 unsigned short iMaxUdpDg;
399 } WSADATA, *LPWSADATA;
402 #define IP_MULTICAST_IF 2
403 #define IP_MULTICAST_TTL 3
404 #define IP_MULTICAST_LOOP 4
405 #define IP_ADD_MEMBERSHIP 5
406 #define IP_DROP_MEMBERSHIP 6
408 #define IP_DEFAULT_MULTICAST_TTL 1
409 #define IP_DEFAULT_MULTICAST_LOOP 1
410 #define IP_MAX_MEMBERSHIPS 20
413 struct in_addr imr_multiaddr;
414 struct in_addr imr_interface;
418 * Definitions related to sockets: types, address families, options,
419 * taken from the BSD file sys/socket.h.
423 * This is used instead of -1, since the
424 * SOCKET type is unsigned.
426 #define INVALID_SOCKET (SOCKET)(~0)
427 #define SOCKET_ERROR (-1)
430 #define SOCK_STREAM 1
434 #define SOCK_SEQPACKET 5
436 /* For setsockoptions(2) */
437 #define SO_DEBUG 0x0001
438 #define SO_ACCEPTCONN 0x0002
439 #define SO_REUSEADDR 0x0004
440 #define SO_KEEPALIVE 0x0008
441 #define SO_DONTROUTE 0x0010
442 #define SO_BROADCAST 0x0020
443 #define SO_USELOOPBACK 0x0040
444 #define SO_LINGER 0x0080
445 #define SO_OOBINLINE 0x0100
447 #define SO_DONTLINGER (u_int)(~SO_LINGER)
450 * Additional options.
452 #define SO_SNDBUF 0x1001 /* send buffer size */
453 #define SO_RCVBUF 0x1002 /* receive buffer size */
454 #define SO_SNDLOWAT 0x1003 /* send low-water mark */
455 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
456 #define SO_SNDTIMEO 0x1005 /* send timeout */
457 #define SO_RCVTIMEO 0x1006 /* receive timeout */
458 #define SO_ERROR 0x1007 /* get error status and clear */
459 #define SO_TYPE 0x1008 /* get socket type */
462 * Options for connect and disconnect data and options. Used only by
463 * non-TCP/IP transports such as DECNet, OSI TP4, etc.
465 #define SO_CONNDATA 0x7000
466 #define SO_CONNOPT 0x7001
467 #define SO_DISCDATA 0x7002
468 #define SO_DISCOPT 0x7003
469 #define SO_CONNDATALEN 0x7004
470 #define SO_CONNOPTLEN 0x7005
471 #define SO_DISCDATALEN 0x7006
472 #define SO_DISCOPTLEN 0x7007
475 * Option for opening sockets for synchronous access.
477 #define SO_OPENTYPE 0x7008
479 #define SO_SYNCHRONOUS_ALERT 0x10
480 #define SO_SYNCHRONOUS_NONALERT 0x20
483 * Other NT-specific options.
485 #define SO_MAXDG 0x7009
486 #define SO_MAXPATHDG 0x700A
491 #define TCP_NODELAY 0x0001
492 #define TCP_BSDURGENT 0x7000
497 #define AF_UNSPEC 0 /* unspecified */
498 #define AF_UNIX 1 /* local to host (pipes, portals) */
499 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
500 #define AF_IMPLINK 3 /* arpanet imp addresses */
501 #define AF_PUP 4 /* pup protocols: e.g. BSP */
502 #define AF_CHAOS 5 /* mit CHAOS protocols */
503 #define AF_IPX 6 /* IPX and SPX */
504 #define AF_NS 6 /* XEROX NS protocols */
505 #define AF_ISO 7 /* ISO protocols */
506 #define AF_OSI AF_ISO /* OSI is ISO */
507 #define AF_ECMA 8 /* european computer manufacturers */
508 #define AF_DATAKIT 9 /* datakit protocols */
509 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
510 #define AF_SNA 11 /* IBM SNA */
511 #define AF_DECnet 12 /* DECnet */
512 #define AF_DLI 13 /* Direct data link interface */
513 #define AF_LAT 14 /* LAT */
514 #define AF_HYLINK 15 /* NSC Hyperchannel */
515 #define AF_APPLETALK 16 /* AppleTalk */
516 #define AF_NETBIOS 17 /* NetBios-style addresses */
521 * Structure used by kernel to store most
530 * Structure used by kernel to pass protocol
531 * information in raw sockets.
539 * Protocol families, same as address families for now.
541 #define PF_UNSPEC AF_UNSPEC
542 #define PF_UNIX AF_UNIX
543 #define PF_INET AF_INET
544 #define PF_IMPLINK AF_IMPLINK
545 #define PF_PUP AF_PUP
546 #define PF_CHAOS AF_CHAOS
548 #define PF_IPX AF_IPX
549 #define PF_ISO AF_ISO
550 #define PF_OSI AF_OSI
551 #define PF_ECMA AF_ECMA
552 #define PF_DATAKIT AF_DATAKIT
553 #define PF_CCITT AF_CCITT
554 #define PF_SNA AF_SNA
555 #define PF_DECnet AF_DECnet
556 #define PF_DLI AF_DLI
557 #define PF_LAT AF_LAT
558 #define PF_HYLINK AF_HYLINK
559 #define PF_APPLETALK AF_APPLETALK
561 #define PF_MAX AF_MAX
564 * Structure used for manipulating linger option.
572 * Level number for (get/set)sockopt() to apply to socket itself.
574 #define SOL_SOCKET 0xffff /* options for socket level */
577 * Maximum queue length specifiable by listen.
581 #define MSG_OOB 0x1 /* process out-of-band data */
582 #define MSG_PEEK 0x2 /* peek at incoming message */
583 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
585 #define MSG_MAXIOVLEN 16
587 #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
590 * Define constant based on rfc883, used by gethostbyxxxx() calls.
592 #define MAXGETHOSTSTRUCT 1024
593 #ifndef MAXHOSTNAMELEN
594 #define MAXHOSTNAMELEN MAXGETHOSTSTRUCT
598 * Define flags to be used with the WSAAsyncSelect() call.
601 #define FD_WRITE 0x02
603 #define FD_ACCEPT 0x08
604 #define FD_CONNECT 0x10
605 #define FD_CLOSE 0x20
608 * All Windows Sockets error constants are biased by WSABASEERR from
611 #define WSABASEERR 10000
613 * Windows Sockets definitions of regular Microsoft C error constants
615 #define WSAEINTR (WSABASEERR+4)
616 #define WSAEBADF (WSABASEERR+9)
617 #define WSAEACCES (WSABASEERR+13)
618 #define WSAEFAULT (WSABASEERR+14)
619 #define WSAEINVAL (WSABASEERR+22)
620 #define WSAEMFILE (WSABASEERR+24)
623 * Windows Sockets definitions of regular Berkeley error constants
625 #define WSAEWOULDBLOCK (WSABASEERR+35)
626 #define WSAEINPROGRESS (WSABASEERR+36)
627 #define WSAEALREADY (WSABASEERR+37)
628 #define WSAENOTSOCK (WSABASEERR+38)
629 #define WSAEDESTADDRREQ (WSABASEERR+39)
630 #define WSAEMSGSIZE (WSABASEERR+40)
631 #define WSAEPROTOTYPE (WSABASEERR+41)
632 #define WSAENOPROTOOPT (WSABASEERR+42)
633 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
634 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
635 #define WSAEOPNOTSUPP (WSABASEERR+45)
636 #define WSAEPFNOSUPPORT (WSABASEERR+46)
637 #define WSAEAFNOSUPPORT (WSABASEERR+47)
638 #define WSAEADDRINUSE (WSABASEERR+48)
639 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
640 #define WSAENETDOWN (WSABASEERR+50)
641 #define WSAENETUNREACH (WSABASEERR+51)
642 #define WSAENETRESET (WSABASEERR+52)
643 #define WSAECONNABORTED (WSABASEERR+53)
644 #define WSAECONNRESET (WSABASEERR+54)
645 #define WSAENOBUFS (WSABASEERR+55)
646 #define WSAEISCONN (WSABASEERR+56)
647 #define WSAENOTCONN (WSABASEERR+57)
648 #define WSAESHUTDOWN (WSABASEERR+58)
649 #define WSAETOOMANYREFS (WSABASEERR+59)
650 #define WSAETIMEDOUT (WSABASEERR+60)
651 #define WSAECONNREFUSED (WSABASEERR+61)
652 #define WSAELOOP (WSABASEERR+62)
653 #define WSAENAMETOOLONG (WSABASEERR+63)
654 #define WSAEHOSTDOWN (WSABASEERR+64)
655 #define WSAEHOSTUNREACH (WSABASEERR+65)
656 #define WSAENOTEMPTY (WSABASEERR+66)
657 #define WSAEPROCLIM (WSABASEERR+67)
658 #define WSAEUSERS (WSABASEERR+68)
659 #define WSAEDQUOT (WSABASEERR+69)
660 #define WSAESTALE (WSABASEERR+70)
661 #define WSAEREMOTE (WSABASEERR+71)
663 #define WSAEDISCON (WSABASEERR+101)
666 * Extended Windows Sockets error constant definitions
668 #define WSASYSNOTREADY (WSABASEERR+91)
669 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
670 #define WSANOTINITIALISED (WSABASEERR+93)
673 * Error return codes from gethostbyname() and gethostbyaddr()
674 * (when using the resolver). Note that these errors are
675 * retrieved via WSAGetLastError() and must therefore follow
676 * the rules for avoiding clashes with error numbers from
677 * specific implementations or language run-time systems.
678 * For this reason the codes are based at WSABASEERR+1001.
679 * Note also that [WSA]NO_ADDRESS is defined only for
680 * compatibility purposes.
683 #define h_errno WSAGetLastError()
685 /* Authoritative Answer: Host not found */
686 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
687 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
689 /* Non-Authoritative: Host not found, or SERVERFAIL */
690 #define WSATRY_AGAIN (WSABASEERR+1002)
691 #define TRY_AGAIN WSATRY_AGAIN
693 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
694 #define WSANO_RECOVERY (WSABASEERR+1003)
695 #define NO_RECOVERY WSANO_RECOVERY
697 /* Valid name, no data record of requested type */
698 #define WSANO_DATA (WSABASEERR+1004)
699 #define NO_DATA WSANO_DATA
701 /* no address, look for MX record */
702 #define WSANO_ADDRESS WSANO_DATA
703 #define NO_ADDRESS WSANO_ADDRESS
706 * Windows Sockets errors redefined as regular Berkeley error constants.
707 * These are commented out in Windows NT to avoid conflicts with errno.h.
708 * Use the WSA constants instead.
711 #define EWOULDBLOCK WSAEWOULDBLOCK
712 #define EINPROGRESS WSAEINPROGRESS
713 #define EALREADY WSAEALREADY
714 #define ENOTSOCK WSAENOTSOCK
715 #define EDESTADDRREQ WSAEDESTADDRREQ
716 #define EMSGSIZE WSAEMSGSIZE
717 #define EPROTOTYPE WSAEPROTOTYPE
718 #define ENOPROTOOPT WSAENOPROTOOPT
719 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
720 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
721 #define EOPNOTSUPP WSAEOPNOTSUPP
722 #define EPFNOSUPPORT WSAEPFNOSUPPORT
723 #define EAFNOSUPPORT WSAEAFNOSUPPORT
724 #define EADDRINUSE WSAEADDRINUSE
725 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
726 #define ENETDOWN WSAENETDOWN
727 #define ENETUNREACH WSAENETUNREACH
728 #define ENETRESET WSAENETRESET
729 #define ECONNABORTED WSAECONNABORTED
730 #define ECONNRESET WSAECONNRESET
731 #define ENOBUFS WSAENOBUFS
732 #define EISCONN WSAEISCONN
733 #define ENOTCONN WSAENOTCONN
734 #define ESHUTDOWN WSAESHUTDOWN
735 #define ETOOMANYREFS WSAETOOMANYREFS
736 #define ETIMEDOUT WSAETIMEDOUT
737 #define ECONNREFUSED WSAECONNREFUSED
738 #define ELOOP WSAELOOP
739 #define ENAMETOOLONG WSAENAMETOOLONG
740 #define EHOSTDOWN WSAEHOSTDOWN
741 #define EHOSTUNREACH WSAEHOSTUNREACH
742 #define ENOTEMPTY WSAENOTEMPTY
743 #define EPROCLIM WSAEPROCLIM
744 #define EUSERS WSAEUSERS
745 #define EDQUOT WSAEDQUOT
746 #define ESTALE WSAESTALE
747 #define EREMOTE WSAEREMOTE
750 /* Socket function prototypes */
752 SOCKET PASCAL accept (SOCKET s, struct sockaddr *addr,
755 int PASCAL bind (SOCKET s, const struct sockaddr *addr, int namelen);
757 int PASCAL closesocket (SOCKET s);
759 int PASCAL connect (SOCKET s, const struct sockaddr *name, int namelen);
761 int PASCAL ioctlsocket (SOCKET s, long cmd, u_long *argp);
763 int PASCAL getpeername (SOCKET s, struct sockaddr *name,
766 int PASCAL getsockname (SOCKET s, struct sockaddr *name,
769 int PASCAL getsockopt (SOCKET s, int level, int optname,
770 char * optval, int *optlen);
772 u_long PASCAL htonl (u_long hostlong);
774 /* For some reason WSOCK.LIB has htons defined as a 4 byte paramter?! */
776 u_short PASCAL htons (u_long hostshort);
778 u_short PASCAL htons (u_short hostshort);
781 unsigned long PASCAL inet_addr (const char * cp);
783 char * PASCAL inet_ntoa (struct in_addr in);
785 int PASCAL listen (SOCKET s, int backlog);
787 u_long PASCAL ntohl (u_long netlong);
789 /* For some reason WSOCK.LIB has ntohs defined as a 4 byte paramter?! */
791 u_short PASCAL ntohs (u_long netshort);
793 u_short PASCAL ntohs (u_short netshort);
796 int PASCAL recv (SOCKET s, char * buf, int len, int flags);
798 int PASCAL recvfrom (SOCKET s, char * buf, int len, int flags,
799 struct sockaddr *from, int * fromlen);
801 int PASCAL select (int nfds, fd_set *readfds, fd_set *writefds,
802 fd_set *exceptfds, const struct timeval *timeout);
804 int PASCAL send (SOCKET s, const char * buf, int len, int flags);
806 int PASCAL sendto (SOCKET s, const char * buf, int len, int flags,
807 const struct sockaddr *to, int tolen);
809 int PASCAL setsockopt (SOCKET s, int level, int optname,
810 const char * optval, int optlen);
812 int PASCAL shutdown (SOCKET s, int how);
814 SOCKET PASCAL socket (int af, int type, int protocol);
816 /* Database function prototypes */
818 struct hostent * PASCAL gethostbyaddr(const char * addr,
821 struct hostent * PASCAL gethostbyname(const char * name);
823 int PASCAL gethostname (char * name, int namelen);
825 struct servent * PASCAL getservbyport(int port, const char * proto);
827 struct servent * PASCAL getservbyname(const char * name,
830 struct protoent * PASCAL getprotobynumber(int proto);
832 struct protoent * PASCAL getprotobyname(const char * name);
834 /* Microsoft Windows Extension function prototypes */
836 /* int PASCAL WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); */
837 int PASCAL WSAStartup(int wVersionRequired, LPWSADATA lpWSAData);
840 int PASCAL WSACleanup(void);
842 void PASCAL WSASetLastError(int iError);
844 int PASCAL WSAGetLastError(void);
846 WINBOOL PASCAL WSAIsBlocking(void);
848 int PASCAL WSAUnhookBlockingHook(void);
850 FARPROC PASCAL WSASetBlockingHook(FARPROC lpBlockFunc);
852 int PASCAL WSACancelBlockingCall(void);
854 HANDLE PASCAL WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
857 char * buf, int buflen);
859 HANDLE PASCAL WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
860 const char * proto, char * buf,
863 HANDLE PASCAL WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
864 const char * name, char * buf,
867 HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
868 int number, char * buf,
871 HANDLE PASCAL WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
872 const char * name, char * buf,
875 HANDLE PASCAL WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
876 const char * addr, int len, int type,
877 char * buf, int buflen);
879 int PASCAL WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
881 int PASCAL WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
884 int PASCAL WSARecvEx (SOCKET s, char * buf, int len, int *flags);
886 /* Microsoft Windows Extended data types */
887 typedef struct sockaddr SOCKADDR;
888 typedef struct sockaddr *PSOCKADDR;
889 typedef struct sockaddr *LPSOCKADDR;
891 typedef struct sockaddr_in SOCKADDR_IN;
892 typedef struct sockaddr_in *PSOCKADDR_IN;
893 typedef struct sockaddr_in *LPSOCKADDR_IN;
895 typedef struct linger LINGER;
896 typedef struct linger *PLINGER;
897 typedef struct linger *LPLINGER;
899 typedef struct in_addr IN_ADDR;
900 typedef struct in_addr *PIN_ADDR;
901 typedef struct in_addr *LPIN_ADDR;
903 typedef struct fd_set FD_SET;
904 typedef struct fd_set *PFD_SET;
905 typedef struct fd_set *LPFD_SET;
907 typedef struct hostent HOSTENT;
908 typedef struct hostent *PHOSTENT;
909 typedef struct hostent *LPHOSTENT;
911 typedef struct servent SERVENT;
912 typedef struct servent *PSERVENT;
913 typedef struct servent *LPSERVENT;
915 typedef struct protoent PROTOENT;
916 typedef struct protoent *PPROTOENT;
917 typedef struct protoent *LPPROTOENT;
919 typedef struct timeval TIMEVAL;
920 typedef struct timeval *PTIMEVAL;
921 typedef struct timeval *LPTIMEVAL;
924 * Windows message parameter composition and decomposition
927 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
928 * when constructing the response to a WSAAsyncGetXByY() routine.
930 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
932 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
933 * when constructing the response to WSAAsyncSelect().
935 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
937 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
938 * to extract the buffer length from the lParam in the response
941 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
943 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
944 * to extract the error code from the lParam in the response
947 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
949 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
950 * to extract the event code from the lParam in the response
951 * to a WSAAsyncSelect().
953 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
955 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
956 * to extract the error code from the lParam in the response
957 * to a WSAAsyncSelect().
959 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
963 #endif /* __cplusplus */
965 #endif /* _GNU_H_WINDOWS32_SOCKETS */