1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets specification.
5 * This file includes parts which are Copyright (c) 1982-1986 Regents
6 * of the University of California. All rights reserved. The
7 * Berkeley Software License Agreement specifies the terms and
8 * conditions for redistribution.
12 * Fri Apr 23 16:31:01 1993 Mark Towfiq (towfiq@Microdyne.COM)
13 * New version from David Treadwell which adds extern "C" around
14 * __WSAFDIsSet() and removes "const" from buf param of
15 * WSAAsyncGetHostByAddr(). Added change log.
17 * Sat May 15 10:55:00 1993 David Treadwell (davidtr@microsoft.com)
18 * Fix the IN_CLASSC macro to account for class-D multicasts.
19 * Add AF_IPX == AF_NS.
27 * Pull in WINDOWS.H if necessary
31 #endif /* _INC_WINDOWS */
34 * Basic system type definitions, taken from the BSD file sys/types.h.
36 typedef unsigned char u_char;
37 typedef unsigned short u_short;
38 typedef unsigned int u_int;
39 typedef unsigned long u_long;
42 * The new type to be used in all
43 * instances which refer to sockets.
48 * Select uses arrays of SOCKETs. These macros manipulate such
49 * arrays. FD_SETSIZE may be defined by the user before including
50 * this file, but the default here should be >= 64.
52 * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
53 * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
57 #endif /* FD_SETSIZE */
59 typedef struct fd_set {
60 u_int fd_count; /* how many are SET? */
61 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
68 extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
75 #define FD_CLR(fd, set) do { \
77 for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
78 if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \
79 while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
80 ((fd_set FAR *)(set))->fd_array[__i] = \
81 ((fd_set FAR *)(set))->fd_array[__i+1]; \
84 ((fd_set FAR *)(set))->fd_count--; \
90 #define FD_SET(fd, set) do { \
91 if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \
92 ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=(fd);\
95 #define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)
97 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))
100 * Structure used in select() call, taken from the BSD file sys/time.h.
103 long tv_sec; /* seconds */
104 long tv_usec; /* and microseconds */
108 * Operations on timevals.
110 * NB: timercmp does not work for >= or <=.
112 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
113 #define timercmp(tvp, uvp, cmp) \
114 ((tvp)->tv_sec cmp (uvp)->tv_sec || \
115 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
116 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
119 * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
122 * Ioctl's have the command encoded in the lower word,
123 * and the size of any in or out parameters in the upper
124 * word. The high 2 bits of the upper word are used
125 * to encode the in/out status of the parameter; for now
126 * we restrict parameters to at most 128 bytes.
128 #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
129 #define IOC_VOID 0x20000000 /* no parameters */
130 #define IOC_OUT 0x40000000 /* copy out parameters */
131 #define IOC_IN 0x80000000 /* copy in parameters */
132 #define IOC_INOUT (IOC_IN|IOC_OUT)
133 /* 0x20000000 distinguishes new &
135 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
137 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
139 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
141 #define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
142 #define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
143 #define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
145 /* Socket I/O Controls */
146 #define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
147 #define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
148 #define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
149 #define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
150 #define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
153 * Structures returned by network data base library, taken from the
154 * BSD file netdb.h. All addresses are supplied in host order, and
155 * returned in network order (suitable for use in system calls).
159 char FAR * h_name; /* official name of host */
160 char FAR * FAR * h_aliases; /* alias list */
161 short h_addrtype; /* host address type */
162 short h_length; /* length of address */
163 char FAR * FAR * h_addr_list; /* list of addresses */
164 #define h_addr h_addr_list[0] /* address, for backward compat */
168 * It is assumed here that a network number
172 char FAR * n_name; /* official name of net */
173 char FAR * FAR * n_aliases; /* alias list */
174 short n_addrtype; /* net address type */
175 u_long n_net; /* network # */
179 char FAR * s_name; /* official service name */
180 char FAR * FAR * s_aliases; /* alias list */
181 short s_port; /* port # */
182 char FAR * s_proto; /* protocol to use */
186 char FAR * p_name; /* official protocol name */
187 char FAR * FAR * p_aliases; /* alias list */
188 short p_proto; /* protocol # */
192 * Constants and structures defined by the internet system,
193 * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
199 #define IPPROTO_IP 0 /* dummy for IP */
200 #define IPPROTO_ICMP 1 /* control message protocol */
201 #define IPPROTO_GGP 2 /* gateway^2 (deprecated) */
202 #define IPPROTO_TCP 6 /* tcp */
203 #define IPPROTO_PUP 12 /* pup */
204 #define IPPROTO_UDP 17 /* user datagram protocol */
205 #define IPPROTO_IDP 22 /* xns idp */
206 #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
208 #define IPPROTO_RAW 255 /* raw IP packet */
209 #define IPPROTO_MAX 256
212 * Port/socket numbers: network standard functions
214 #define IPPORT_ECHO 7
215 #define IPPORT_DISCARD 9
216 #define IPPORT_SYSTAT 11
217 #define IPPORT_DAYTIME 13
218 #define IPPORT_NETSTAT 15
219 #define IPPORT_FTP 21
220 #define IPPORT_TELNET 23
221 #define IPPORT_SMTP 25
222 #define IPPORT_TIMESERVER 37
223 #define IPPORT_NAMESERVER 42
224 #define IPPORT_WHOIS 43
225 #define IPPORT_MTP 57
228 * Port/socket numbers: host specific functions
230 #define IPPORT_TFTP 69
231 #define IPPORT_RJE 77
232 #define IPPORT_FINGER 79
233 #define IPPORT_TTYLINK 87
234 #define IPPORT_SUPDUP 95
239 #define IPPORT_EXECSERVER 512
240 #define IPPORT_LOGINSERVER 513
241 #define IPPORT_CMDSERVER 514
242 #define IPPORT_EFSSERVER 520
247 #define IPPORT_BIFFUDP 512
248 #define IPPORT_WHOSERVER 513
249 #define IPPORT_ROUTESERVER 520
250 /* 520+1 also used */
253 * Ports < IPPORT_RESERVED are reserved for
254 * privileged processes (e.g. root).
256 #define IPPORT_RESERVED 1024
261 #define IMPLINK_IP 155
262 #define IMPLINK_LOWEXPER 156
263 #define IMPLINK_HIGHEXPER 158
266 * Internet address (old style... should be updated)
270 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
271 struct { u_short s_w1,s_w2; } S_un_w;
274 #define s_addr S_un.S_addr
275 /* can be used for most tcp & ip code */
276 #define s_host S_un.S_un_b.s_b2
278 #define s_net S_un.S_un_b.s_b1
280 #define s_imp S_un.S_un_w.s_w2
282 #define s_impno S_un.S_un_b.s_b4
284 #define s_lh S_un.S_un_b.s_b3
289 * Definitions of bits in internet address integers.
290 * On subnets, the decomposition of addresses to host and net parts
291 * is done according to subnet mask, not the masks here.
293 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
294 #define IN_CLASSA_NET 0xff000000
295 #define IN_CLASSA_NSHIFT 24
296 #define IN_CLASSA_HOST 0x00ffffff
297 #define IN_CLASSA_MAX 128
299 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
300 #define IN_CLASSB_NET 0xffff0000
301 #define IN_CLASSB_NSHIFT 16
302 #define IN_CLASSB_HOST 0x0000ffff
303 #define IN_CLASSB_MAX 65536
305 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
306 #define IN_CLASSC_NET 0xffffff00
307 #define IN_CLASSC_NSHIFT 8
308 #define IN_CLASSC_HOST 0x000000ff
310 #define INADDR_ANY (u_long)0x00000000
311 #define INADDR_LOOPBACK 0x7f000001
312 #define INADDR_BROADCAST (u_long)0xffffffff
313 #define INADDR_NONE 0xffffffff
316 * Socket address, internet style.
321 struct in_addr sin_addr;
325 #define WSADESCRIPTION_LEN 256
326 #define WSASYS_STATUS_LEN 128
328 typedef struct WSAData {
331 char szDescription[WSADESCRIPTION_LEN+1];
332 char szSystemStatus[WSASYS_STATUS_LEN+1];
333 unsigned short iMaxSockets;
334 unsigned short iMaxUdpDg;
335 char FAR * lpVendorInfo;
338 typedef WSADATA FAR *LPWSADATA;
341 * Options for use with [gs]etsockopt at the IP level.
343 #define IP_OPTIONS 1 /* set/get IP per-packet options */
344 #define IP_MULTICAST_IF 2 /* set/get IP multicast interface */
345 #define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */
346 #define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */
347 #define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */
348 #define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */
350 #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
351 #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
352 #define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
355 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
358 struct in_addr imr_multiaddr; /* IP multicast address of group */
359 struct in_addr imr_interface; /* local IP address of interface */
363 * Definitions related to sockets: types, address families, options,
364 * taken from the BSD file sys/socket.h.
368 * This is used instead of -1, since the
369 * SOCKET type is unsigned.
371 #define INVALID_SOCKET (SOCKET)(~0)
372 #define SOCKET_ERROR (-1)
377 #define SOCK_STREAM 1 /* stream socket */
378 #define SOCK_DGRAM 2 /* datagram socket */
379 #define SOCK_RAW 3 /* raw-protocol interface */
380 #define SOCK_RDM 4 /* reliably-delivered message */
381 #define SOCK_SEQPACKET 5 /* sequenced packet stream */
384 * Option flags per-socket.
386 #define SO_DEBUG 0x0001 /* turn on debugging info recording */
387 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
388 #define SO_REUSEADDR 0x0004 /* allow local address reuse */
389 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
390 #define SO_DONTROUTE 0x0010 /* just use interface addresses */
391 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
392 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
393 #define SO_LINGER 0x0080 /* linger on close if data present */
394 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
396 #define SO_DONTLINGER (u_int)(~SO_LINGER)
399 * Additional options.
401 #define SO_SNDBUF 0x1001 /* send buffer size */
402 #define SO_RCVBUF 0x1002 /* receive buffer size */
403 #define SO_SNDLOWAT 0x1003 /* send low-water mark */
404 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
405 #define SO_SNDTIMEO 0x1005 /* send timeout */
406 #define SO_RCVTIMEO 0x1006 /* receive timeout */
407 #define SO_ERROR 0x1007 /* get error status and clear */
408 #define SO_TYPE 0x1008 /* get socket type */
411 * Options for connect and disconnect data and options. Used only by
412 * non-TCP/IP transports such as DECNet, OSI TP4, etc.
414 #define SO_CONNDATA 0x7000
415 #define SO_CONNOPT 0x7001
416 #define SO_DISCDATA 0x7002
417 #define SO_DISCOPT 0x7003
418 #define SO_CONNDATALEN 0x7004
419 #define SO_CONNOPTLEN 0x7005
420 #define SO_DISCDATALEN 0x7006
421 #define SO_DISCOPTLEN 0x7007
424 * Option for opening sockets for synchronous access.
426 #define SO_OPENTYPE 0x7008
428 #define SO_SYNCHRONOUS_ALERT 0x10
429 #define SO_SYNCHRONOUS_NONALERT 0x20
432 * Other NT-specific options.
434 #define SO_MAXDG 0x7009
435 #define SO_MAXPATHDG 0x700A
440 #define TCP_NODELAY 0x0001
441 #define TCP_BSDURGENT 0x7000
446 #define AF_UNSPEC 0 /* unspecified */
447 #define AF_UNIX 1 /* local to host (pipes, portals) */
448 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
449 #define AF_IMPLINK 3 /* arpanet imp addresses */
450 #define AF_PUP 4 /* pup protocols: e.g. BSP */
451 #define AF_CHAOS 5 /* mit CHAOS protocols */
452 #define AF_IPX 6 /* IPX and SPX */
453 #define AF_NS 6 /* XEROX NS protocols */
454 #define AF_ISO 7 /* ISO protocols */
455 #define AF_OSI AF_ISO /* OSI is ISO */
456 #define AF_ECMA 8 /* european computer manufacturers */
457 #define AF_DATAKIT 9 /* datakit protocols */
458 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
459 #define AF_SNA 11 /* IBM SNA */
460 #define AF_DECnet 12 /* DECnet */
461 #define AF_DLI 13 /* Direct data link interface */
462 #define AF_LAT 14 /* LAT */
463 #define AF_HYLINK 15 /* NSC Hyperchannel */
464 #define AF_APPLETALK 16 /* AppleTalk */
465 #define AF_NETBIOS 17 /* NetBios-style addresses */
470 * Structure used by kernel to store most
474 u_short sa_family; /* address family */
475 char sa_data[14]; /* up to 14 bytes of direct address */
479 * Structure used by kernel to pass protocol
480 * information in raw sockets.
483 u_short sp_family; /* address family */
484 u_short sp_protocol; /* protocol */
488 * Protocol families, same as address families for now.
490 #define PF_UNSPEC AF_UNSPEC
491 #define PF_UNIX AF_UNIX
492 #define PF_INET AF_INET
493 #define PF_IMPLINK AF_IMPLINK
494 #define PF_PUP AF_PUP
495 #define PF_CHAOS AF_CHAOS
497 #define PF_IPX AF_IPX
498 #define PF_ISO AF_ISO
499 #define PF_OSI AF_OSI
500 #define PF_ECMA AF_ECMA
501 #define PF_DATAKIT AF_DATAKIT
502 #define PF_CCITT AF_CCITT
503 #define PF_SNA AF_SNA
504 #define PF_DECnet AF_DECnet
505 #define PF_DLI AF_DLI
506 #define PF_LAT AF_LAT
507 #define PF_HYLINK AF_HYLINK
508 #define PF_APPLETALK AF_APPLETALK
510 #define PF_MAX AF_MAX
513 * Structure used for manipulating linger option.
516 u_short l_onoff; /* option on/off */
517 u_short l_linger; /* linger time */
521 * Level number for (get/set)sockopt() to apply to socket itself.
523 #define SOL_SOCKET 0xffff /* options for socket level */
526 * Maximum queue length specifiable by listen.
530 #define MSG_OOB 0x1 /* process out-of-band data */
531 #define MSG_PEEK 0x2 /* peek at incoming message */
532 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
534 #define MSG_MAXIOVLEN 16
536 #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
539 * Define constant based on rfc883, used by gethostbyxxxx() calls.
541 #define MAXGETHOSTSTRUCT 1024
544 * Define flags to be used with the WSAAsyncSelect() call.
547 #define FD_WRITE 0x02
549 #define FD_ACCEPT 0x08
550 #define FD_CONNECT 0x10
551 #define FD_CLOSE 0x20
554 * All Windows Sockets error constants are biased by WSABASEERR from
557 #define WSABASEERR 10000
559 * Windows Sockets definitions of regular Microsoft C error constants
561 #define WSAEINTR (WSABASEERR+4)
562 #define WSAEBADF (WSABASEERR+9)
563 #define WSAEACCES (WSABASEERR+13)
564 #define WSAEFAULT (WSABASEERR+14)
565 #define WSAEINVAL (WSABASEERR+22)
566 #define WSAEMFILE (WSABASEERR+24)
569 * Windows Sockets definitions of regular Berkeley error constants
571 #define WSAEWOULDBLOCK (WSABASEERR+35)
572 #define WSAEINPROGRESS (WSABASEERR+36)
573 #define WSAEALREADY (WSABASEERR+37)
574 #define WSAENOTSOCK (WSABASEERR+38)
575 #define WSAEDESTADDRREQ (WSABASEERR+39)
576 #define WSAEMSGSIZE (WSABASEERR+40)
577 #define WSAEPROTOTYPE (WSABASEERR+41)
578 #define WSAENOPROTOOPT (WSABASEERR+42)
579 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
580 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
581 #define WSAEOPNOTSUPP (WSABASEERR+45)
582 #define WSAEPFNOSUPPORT (WSABASEERR+46)
583 #define WSAEAFNOSUPPORT (WSABASEERR+47)
584 #define WSAEADDRINUSE (WSABASEERR+48)
585 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
586 #define WSAENETDOWN (WSABASEERR+50)
587 #define WSAENETUNREACH (WSABASEERR+51)
588 #define WSAENETRESET (WSABASEERR+52)
589 #define WSAECONNABORTED (WSABASEERR+53)
590 #define WSAECONNRESET (WSABASEERR+54)
591 #define WSAENOBUFS (WSABASEERR+55)
592 #define WSAEISCONN (WSABASEERR+56)
593 #define WSAENOTCONN (WSABASEERR+57)
594 #define WSAESHUTDOWN (WSABASEERR+58)
595 #define WSAETOOMANYREFS (WSABASEERR+59)
596 #define WSAETIMEDOUT (WSABASEERR+60)
597 #define WSAECONNREFUSED (WSABASEERR+61)
598 #define WSAELOOP (WSABASEERR+62)
599 #define WSAENAMETOOLONG (WSABASEERR+63)
600 #define WSAEHOSTDOWN (WSABASEERR+64)
601 #define WSAEHOSTUNREACH (WSABASEERR+65)
602 #define WSAENOTEMPTY (WSABASEERR+66)
603 #define WSAEPROCLIM (WSABASEERR+67)
604 #define WSAEUSERS (WSABASEERR+68)
605 #define WSAEDQUOT (WSABASEERR+69)
606 #define WSAESTALE (WSABASEERR+70)
607 #define WSAEREMOTE (WSABASEERR+71)
609 #define WSAEDISCON (WSABASEERR+101)
612 * Extended Windows Sockets error constant definitions
614 #define WSASYSNOTREADY (WSABASEERR+91)
615 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
616 #define WSANOTINITIALISED (WSABASEERR+93)
619 * Error return codes from gethostbyname() and gethostbyaddr()
620 * (when using the resolver). Note that these errors are
621 * retrieved via WSAGetLastError() and must therefore follow
622 * the rules for avoiding clashes with error numbers from
623 * specific implementations or language run-time systems.
624 * For this reason the codes are based at WSABASEERR+1001.
625 * Note also that [WSA]NO_ADDRESS is defined only for
626 * compatibility purposes.
629 #define h_errno WSAGetLastError()
631 /* Authoritative Answer: Host not found */
632 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
633 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
635 /* Non-Authoritative: Host not found, or SERVERFAIL */
636 #define WSATRY_AGAIN (WSABASEERR+1002)
637 #define TRY_AGAIN WSATRY_AGAIN
639 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
640 #define WSANO_RECOVERY (WSABASEERR+1003)
641 #define NO_RECOVERY WSANO_RECOVERY
643 /* Valid name, no data record of requested type */
644 #define WSANO_DATA (WSABASEERR+1004)
645 #define NO_DATA WSANO_DATA
647 /* no address, look for MX record */
648 #define WSANO_ADDRESS WSANO_DATA
649 #define NO_ADDRESS WSANO_ADDRESS
652 * Windows Sockets errors redefined as regular Berkeley error constants.
653 * These are commented out in Windows NT to avoid conflicts with errno.h.
654 * Use the WSA constants instead.
657 #define EWOULDBLOCK WSAEWOULDBLOCK
658 #define EINPROGRESS WSAEINPROGRESS
659 #define EALREADY WSAEALREADY
660 #define ENOTSOCK WSAENOTSOCK
661 #define EDESTADDRREQ WSAEDESTADDRREQ
662 #define EMSGSIZE WSAEMSGSIZE
663 #define EPROTOTYPE WSAEPROTOTYPE
664 #define ENOPROTOOPT WSAENOPROTOOPT
665 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
666 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
667 #define EOPNOTSUPP WSAEOPNOTSUPP
668 #define EPFNOSUPPORT WSAEPFNOSUPPORT
669 #define EAFNOSUPPORT WSAEAFNOSUPPORT
670 #define EADDRINUSE WSAEADDRINUSE
671 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
672 #define ENETDOWN WSAENETDOWN
673 #define ENETUNREACH WSAENETUNREACH
674 #define ENETRESET WSAENETRESET
675 #define ECONNABORTED WSAECONNABORTED
676 #define ECONNRESET WSAECONNRESET
677 #define ENOBUFS WSAENOBUFS
678 #define EISCONN WSAEISCONN
679 #define ENOTCONN WSAENOTCONN
680 #define ESHUTDOWN WSAESHUTDOWN
681 #define ETOOMANYREFS WSAETOOMANYREFS
682 #define ETIMEDOUT WSAETIMEDOUT
683 #define ECONNREFUSED WSAECONNREFUSED
684 #define ELOOP WSAELOOP
685 #define ENAMETOOLONG WSAENAMETOOLONG
686 #define EHOSTDOWN WSAEHOSTDOWN
687 #define EHOSTUNREACH WSAEHOSTUNREACH
688 #define ENOTEMPTY WSAENOTEMPTY
689 #define EPROCLIM WSAEPROCLIM
690 #define EUSERS WSAEUSERS
691 #define EDQUOT WSAEDQUOT
692 #define ESTALE WSAESTALE
693 #define EREMOTE WSAEREMOTE
696 /* Socket function prototypes */
702 SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr,
705 int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *addr, int namelen);
707 int PASCAL FAR closesocket (SOCKET s);
709 int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
711 int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp);
713 int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name,
716 int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name,
719 int PASCAL FAR getsockopt (SOCKET s, int level, int optname,
720 char FAR * optval, int FAR *optlen);
722 u_long PASCAL FAR htonl (u_long hostlong);
724 u_short PASCAL FAR htons (u_short hostshort);
726 unsigned long PASCAL FAR inet_addr (const char FAR * cp);
728 char FAR * PASCAL FAR inet_ntoa (struct in_addr in);
730 int PASCAL FAR listen (SOCKET s, int backlog);
732 u_long PASCAL FAR ntohl (u_long netlong);
734 u_short PASCAL FAR ntohs (u_short netshort);
736 int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags);
738 int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags,
739 struct sockaddr FAR *from, int FAR * fromlen);
741 int PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set FAR *writefds,
742 fd_set FAR *exceptfds, const struct timeval FAR *timeout);
744 int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int flags);
746 int PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, int flags,
747 const struct sockaddr FAR *to, int tolen);
749 int PASCAL FAR setsockopt (SOCKET s, int level, int optname,
750 const char FAR * optval, int optlen);
752 int PASCAL FAR shutdown (SOCKET s, int how);
754 SOCKET PASCAL FAR socket (int af, int type, int protocol);
756 /* Database function prototypes */
758 struct hostent FAR * PASCAL FAR gethostbyaddr(const char FAR * addr,
761 struct hostent FAR * PASCAL FAR gethostbyname(const char FAR * name);
763 int PASCAL FAR gethostname (char FAR * name, int namelen);
765 struct servent FAR * PASCAL FAR getservbyport(int port, const char FAR * proto);
767 struct servent FAR * PASCAL FAR getservbyname(const char FAR * name,
768 const char FAR * proto);
770 struct protoent FAR * PASCAL FAR getprotobynumber(int proto);
772 struct protoent FAR * PASCAL FAR getprotobyname(const char FAR * name);
774 /* Microsoft Windows Extension function prototypes */
776 int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
778 int PASCAL FAR WSACleanup(void);
780 void PASCAL FAR WSASetLastError(int iError);
782 int PASCAL FAR WSAGetLastError(void);
784 BOOL PASCAL FAR WSAIsBlocking(void);
786 int PASCAL FAR WSAUnhookBlockingHook(void);
788 FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc);
790 int PASCAL FAR WSACancelBlockingCall(void);
792 HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
793 const char FAR * name,
794 const char FAR * proto,
795 char FAR * buf, int buflen);
797 HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
798 const char FAR * proto, char FAR * buf,
801 HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
802 const char FAR * name, char FAR * buf,
805 HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
806 int number, char FAR * buf,
809 HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
810 const char FAR * name, char FAR * buf,
813 HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
814 const char FAR * addr, int len, int type,
815 char FAR * buf, int buflen);
817 int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
819 int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
822 int PASCAL FAR WSARecvEx (SOCKET s, char FAR * buf, int len, int FAR *flags);
828 /* Microsoft Windows Extended data types */
829 typedef struct sockaddr SOCKADDR;
830 typedef struct sockaddr *PSOCKADDR;
831 typedef struct sockaddr FAR *LPSOCKADDR;
833 typedef struct sockaddr_in SOCKADDR_IN;
834 typedef struct sockaddr_in *PSOCKADDR_IN;
835 typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
837 typedef struct linger LINGER;
838 typedef struct linger *PLINGER;
839 typedef struct linger FAR *LPLINGER;
841 typedef struct in_addr IN_ADDR;
842 typedef struct in_addr *PIN_ADDR;
843 typedef struct in_addr FAR *LPIN_ADDR;
845 typedef struct fd_set FD_SET;
846 typedef struct fd_set *PFD_SET;
847 typedef struct fd_set FAR *LPFD_SET;
849 typedef struct hostent HOSTENT;
850 typedef struct hostent *PHOSTENT;
851 typedef struct hostent FAR *LPHOSTENT;
853 typedef struct servent SERVENT;
854 typedef struct servent *PSERVENT;
855 typedef struct servent FAR *LPSERVENT;
857 typedef struct protoent PROTOENT;
858 typedef struct protoent *PPROTOENT;
859 typedef struct protoent FAR *LPPROTOENT;
861 typedef struct timeval TIMEVAL;
862 typedef struct timeval *PTIMEVAL;
863 typedef struct timeval FAR *LPTIMEVAL;
866 * Windows message parameter composition and decomposition
869 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
870 * when constructing the response to a WSAAsyncGetXByY() routine.
872 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
874 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
875 * when constructing the response to WSAAsyncSelect().
877 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
879 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
880 * to extract the buffer length from the lParam in the response
883 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
885 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
886 * to extract the error code from the lParam in the response
889 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
891 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
892 * to extract the event code from the lParam in the response
893 * to a WSAAsyncSelect().
895 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
897 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
898 * to extract the error code from the lParam in the response
899 * to a WSAAsyncSelect().
901 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
903 #endif /* _WINSOCKAPI_ */