]> git.sur5r.net Git - openldap/blob - libraries/msdos/winsock/include/wsa/winsock.h
no longer supported.
[openldap] / libraries / msdos / winsock / include / wsa / winsock.h
1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
2  *
3  * This header file corresponds to version 1.1 of the Windows Sockets specification.
4  *
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.
9  *
10  * Change log:
11  *
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.
16  *
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.
20  *
21  */
22
23 #ifndef _WINSOCKAPI_
24 #define _WINSOCKAPI_
25
26 /*
27  * Pull in WINDOWS.H if necessary
28  */
29 #ifndef _INC_WINDOWS
30 #include <windows.h>
31 #endif /* _INC_WINDOWS */
32
33 /*
34  * Basic system type definitions, taken from the BSD file sys/types.h.
35  */
36 typedef unsigned char   u_char;
37 typedef unsigned short  u_short;
38 typedef unsigned int    u_int;
39 typedef unsigned long   u_long;
40
41 /*
42  * The new type to be used in all
43  * instances which refer to sockets.
44  */
45 typedef u_int           SOCKET;
46
47 /*
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.
51  *
52  * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
53  * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
54  */
55 #ifndef FD_SETSIZE
56 #define FD_SETSIZE      64
57 #endif /* FD_SETSIZE */
58
59 typedef struct fd_set {
60         u_int   fd_count;               /* how many are SET? */
61         SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
62 } fd_set;
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
68 extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74
75 #define FD_CLR(fd, set) do { \
76     u_int __i; \
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]; \
82                 __i++; \
83             } \
84             ((fd_set FAR *)(set))->fd_count--; \
85             break; \
86         } \
87     } \
88 } while(0)
89
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);\
93 } while(0)
94
95 #define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)
96
97 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))
98
99 /*
100  * Structure used in select() call, taken from the BSD file sys/time.h.
101  */
102 struct timeval {
103         long    tv_sec;         /* seconds */
104         long    tv_usec;        /* and microseconds */
105 };
106
107 /*
108  * Operations on timevals.
109  *
110  * NB: timercmp does not work for >= or <=.
111  */
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
117
118 /*
119  * Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
120  *
121  *
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.
127  */
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 &
134                                            old ioctl's */
135 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
136
137 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
138
139 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
140
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 */
144
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? */
151
152 /*
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).
156  */
157
158 struct  hostent {
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 */
165 };
166
167 /*
168  * It is assumed here that a network number
169  * fits in 32 bits.
170  */
171 struct  netent {
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 # */
176 };
177
178 struct  servent {
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 */
183 };
184
185 struct  protoent {
186         char    FAR * p_name;           /* official protocol name */
187         char    FAR * FAR * p_aliases;  /* alias list */
188         short   p_proto;                /* protocol # */
189 };
190
191 /*
192  * Constants and structures defined by the internet system,
193  * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
194  */
195
196 /*
197  * Protocols
198  */
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 */
207
208 #define IPPROTO_RAW             255             /* raw IP packet */
209 #define IPPROTO_MAX             256
210
211 /*
212  * Port/socket numbers: network standard functions
213  */
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
226
227 /*
228  * Port/socket numbers: host specific functions
229  */
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
235
236 /*
237  * UNIX TCP sockets
238  */
239 #define IPPORT_EXECSERVER       512
240 #define IPPORT_LOGINSERVER      513
241 #define IPPORT_CMDSERVER        514
242 #define IPPORT_EFSSERVER        520
243
244 /*
245  * UNIX UDP sockets
246  */
247 #define IPPORT_BIFFUDP          512
248 #define IPPORT_WHOSERVER        513
249 #define IPPORT_ROUTESERVER      520
250                                         /* 520+1 also used */
251
252 /*
253  * Ports < IPPORT_RESERVED are reserved for
254  * privileged processes (e.g. root).
255  */
256 #define IPPORT_RESERVED         1024
257
258 /*
259  * Link numbers
260  */
261 #define IMPLINK_IP              155
262 #define IMPLINK_LOWEXPER        156
263 #define IMPLINK_HIGHEXPER       158
264
265 /*
266  * Internet address (old style... should be updated)
267  */
268 struct in_addr {
269         union {
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;
272                 u_long S_addr;
273         } S_un;
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
277                                 /* host on imp */
278 #define s_net   S_un.S_un_b.s_b1
279                                 /* network */
280 #define s_imp   S_un.S_un_w.s_w2
281                                 /* imp */
282 #define s_impno S_un.S_un_b.s_b4
283                                 /* imp # */
284 #define s_lh    S_un.S_un_b.s_b3
285                                 /* logical host */
286 };
287
288 /*
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.
292  */
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
298
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
304
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
309
310 #define INADDR_ANY              (u_long)0x00000000
311 #define INADDR_LOOPBACK         0x7f000001
312 #define INADDR_BROADCAST        (u_long)0xffffffff
313 #define INADDR_NONE             0xffffffff
314
315 /*
316  * Socket address, internet style.
317  */
318 struct sockaddr_in {
319         short   sin_family;
320         u_short sin_port;
321         struct  in_addr sin_addr;
322         char    sin_zero[8];
323 };
324
325 #define WSADESCRIPTION_LEN      256
326 #define WSASYS_STATUS_LEN       128
327
328 typedef struct WSAData {
329         WORD                    wVersion;
330         WORD                    wHighVersion;
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;
336 } WSADATA;
337
338 typedef WSADATA FAR *LPWSADATA;
339
340 /*
341  * Options for use with [gs]etsockopt at the IP level.
342  */
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      */
349
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 */
353
354 /*
355  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
356  */
357 struct ip_mreq {
358         struct in_addr  imr_multiaddr;  /* IP multicast address of group */
359         struct in_addr  imr_interface;  /* local IP address of interface */
360 };
361
362 /*
363  * Definitions related to sockets: types, address families, options,
364  * taken from the BSD file sys/socket.h.
365  */
366
367 /*
368  * This is used instead of -1, since the
369  * SOCKET type is unsigned.
370  */
371 #define INVALID_SOCKET  (SOCKET)(~0)
372 #define SOCKET_ERROR            (-1)
373
374 /*
375  * Types
376  */
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 */
382
383 /*
384  * Option flags per-socket.
385  */
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 */
395
396 #define SO_DONTLINGER   (u_int)(~SO_LINGER)
397
398 /*
399  * Additional options.
400  */
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 */
409
410 /*
411  * Options for connect and disconnect data and options.  Used only by
412  * non-TCP/IP transports such as DECNet, OSI TP4, etc.
413  */
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
422
423 /*
424  * Option for opening sockets for synchronous access.
425  */
426 #define SO_OPENTYPE     0x7008
427
428 #define SO_SYNCHRONOUS_ALERT    0x10
429 #define SO_SYNCHRONOUS_NONALERT 0x20
430
431 /*
432  * Other NT-specific options.
433  */
434 #define SO_MAXDG        0x7009
435 #define SO_MAXPATHDG    0x700A
436
437 /*
438  * TCP options.
439  */
440 #define TCP_NODELAY     0x0001
441 #define TCP_BSDURGENT   0x7000
442
443 /*
444  * Address families.
445  */
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 */
466
467 #define AF_MAX          18
468
469 /*
470  * Structure used by kernel to store most
471  * addresses.
472  */
473 struct sockaddr {
474         u_short sa_family;              /* address family */
475         char    sa_data[14];            /* up to 14 bytes of direct address */
476 };
477
478 /*
479  * Structure used by kernel to pass protocol
480  * information in raw sockets.
481  */
482 struct sockproto {
483         u_short sp_family;              /* address family */
484         u_short sp_protocol;            /* protocol */
485 };
486
487 /*
488  * Protocol families, same as address families for now.
489  */
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
496 #define PF_NS           AF_NS
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
509
510 #define PF_MAX          AF_MAX
511
512 /*
513  * Structure used for manipulating linger option.
514  */
515 struct  linger {
516         u_short l_onoff;                /* option on/off */
517         u_short l_linger;               /* linger time */
518 };
519
520 /*
521  * Level number for (get/set)sockopt() to apply to socket itself.
522  */
523 #define SOL_SOCKET      0xffff          /* options for socket level */
524
525 /*
526  * Maximum queue length specifiable by listen.
527  */
528 #define SOMAXCONN       5
529
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 */
533
534 #define MSG_MAXIOVLEN   16
535
536 #define MSG_PARTIAL     0x8000          /* partial send or recv for message xport */
537
538 /*
539  * Define constant based on rfc883, used by gethostbyxxxx() calls.
540  */
541 #define MAXGETHOSTSTRUCT        1024
542
543 /*
544  * Define flags to be used with the WSAAsyncSelect() call.
545  */
546 #define FD_READ         0x01
547 #define FD_WRITE        0x02
548 #define FD_OOB          0x04
549 #define FD_ACCEPT       0x08
550 #define FD_CONNECT      0x10
551 #define FD_CLOSE        0x20
552
553 /*
554  * All Windows Sockets error constants are biased by WSABASEERR from
555  * the "normal"
556  */
557 #define WSABASEERR              10000
558 /*
559  * Windows Sockets definitions of regular Microsoft C error constants
560  */
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)
567
568 /*
569  * Windows Sockets definitions of regular Berkeley error constants
570  */
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)
608
609 #define WSAEDISCON              (WSABASEERR+101)
610
611 /*
612  * Extended Windows Sockets error constant definitions
613  */
614 #define WSASYSNOTREADY          (WSABASEERR+91)
615 #define WSAVERNOTSUPPORTED      (WSABASEERR+92)
616 #define WSANOTINITIALISED       (WSABASEERR+93)
617
618 /*
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.
627  */
628
629 #define h_errno         WSAGetLastError()
630
631 /* Authoritative Answer: Host not found */
632 #define WSAHOST_NOT_FOUND       (WSABASEERR+1001)
633 #define HOST_NOT_FOUND          WSAHOST_NOT_FOUND
634
635 /* Non-Authoritative: Host not found, or SERVERFAIL */
636 #define WSATRY_AGAIN            (WSABASEERR+1002)
637 #define TRY_AGAIN               WSATRY_AGAIN
638
639 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
640 #define WSANO_RECOVERY          (WSABASEERR+1003)
641 #define NO_RECOVERY             WSANO_RECOVERY
642
643 /* Valid name, no data record of requested type */
644 #define WSANO_DATA              (WSABASEERR+1004)
645 #define NO_DATA                 WSANO_DATA
646
647 /* no address, look for MX record */
648 #define WSANO_ADDRESS           WSANO_DATA
649 #define NO_ADDRESS              WSANO_ADDRESS
650
651 /*
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.
655  */
656 #if 0
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
694 #endif
695
696 /* Socket function prototypes */
697
698 #ifdef __cplusplus
699 extern "C" {
700 #endif
701
702 SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr,
703                           int FAR *addrlen);
704
705 int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *addr, int namelen);
706
707 int PASCAL FAR closesocket (SOCKET s);
708
709 int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
710
711 int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp);
712
713 int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name,
714                             int FAR * namelen);
715
716 int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name,
717                             int FAR * namelen);
718
719 int PASCAL FAR getsockopt (SOCKET s, int level, int optname,
720                            char FAR * optval, int FAR *optlen);
721
722 u_long PASCAL FAR htonl (u_long hostlong);
723
724 u_short PASCAL FAR htons (u_short hostshort);
725
726 unsigned long PASCAL FAR inet_addr (const char FAR * cp);
727
728 char FAR * PASCAL FAR inet_ntoa (struct in_addr in);
729
730 int PASCAL FAR listen (SOCKET s, int backlog);
731
732 u_long PASCAL FAR ntohl (u_long netlong);
733
734 u_short PASCAL FAR ntohs (u_short netshort);
735
736 int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags);
737
738 int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags,
739                          struct sockaddr FAR *from, int FAR * fromlen);
740
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);
743
744 int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int flags);
745
746 int PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, int flags,
747                        const struct sockaddr FAR *to, int tolen);
748
749 int PASCAL FAR setsockopt (SOCKET s, int level, int optname,
750                            const char FAR * optval, int optlen);
751
752 int PASCAL FAR shutdown (SOCKET s, int how);
753
754 SOCKET PASCAL FAR socket (int af, int type, int protocol);
755
756 /* Database function prototypes */
757
758 struct hostent FAR * PASCAL FAR gethostbyaddr(const char FAR * addr,
759                                               int len, int type);
760
761 struct hostent FAR * PASCAL FAR gethostbyname(const char FAR * name);
762
763 int PASCAL FAR gethostname (char FAR * name, int namelen);
764
765 struct servent FAR * PASCAL FAR getservbyport(int port, const char FAR * proto);
766
767 struct servent FAR * PASCAL FAR getservbyname(const char FAR * name,
768                                               const char FAR * proto);
769
770 struct protoent FAR * PASCAL FAR getprotobynumber(int proto);
771
772 struct protoent FAR * PASCAL FAR getprotobyname(const char FAR * name);
773
774 /* Microsoft Windows Extension function prototypes */
775
776 int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
777
778 int PASCAL FAR WSACleanup(void);
779
780 void PASCAL FAR WSASetLastError(int iError);
781
782 int PASCAL FAR WSAGetLastError(void);
783
784 BOOL PASCAL FAR WSAIsBlocking(void);
785
786 int PASCAL FAR WSAUnhookBlockingHook(void);
787
788 FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc);
789
790 int PASCAL FAR WSACancelBlockingCall(void);
791
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);
796
797 HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
798                                         const char FAR * proto, char FAR * buf,
799                                         int buflen);
800
801 HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
802                                          const char FAR * name, char FAR * buf,
803                                          int buflen);
804
805 HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
806                                            int number, char FAR * buf,
807                                            int buflen);
808
809 HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
810                                         const char FAR * name, char FAR * buf,
811                                         int buflen);
812
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);
816
817 int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
818
819 int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
820                                long lEvent);
821
822 int PASCAL FAR WSARecvEx (SOCKET s, char FAR * buf, int len, int FAR *flags);
823
824 #ifdef __cplusplus
825 }
826 #endif
827
828 /* Microsoft Windows Extended data types */
829 typedef struct sockaddr SOCKADDR;
830 typedef struct sockaddr *PSOCKADDR;
831 typedef struct sockaddr FAR *LPSOCKADDR;
832
833 typedef struct sockaddr_in SOCKADDR_IN;
834 typedef struct sockaddr_in *PSOCKADDR_IN;
835 typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
836
837 typedef struct linger LINGER;
838 typedef struct linger *PLINGER;
839 typedef struct linger FAR *LPLINGER;
840
841 typedef struct in_addr IN_ADDR;
842 typedef struct in_addr *PIN_ADDR;
843 typedef struct in_addr FAR *LPIN_ADDR;
844
845 typedef struct fd_set FD_SET;
846 typedef struct fd_set *PFD_SET;
847 typedef struct fd_set FAR *LPFD_SET;
848
849 typedef struct hostent HOSTENT;
850 typedef struct hostent *PHOSTENT;
851 typedef struct hostent FAR *LPHOSTENT;
852
853 typedef struct servent SERVENT;
854 typedef struct servent *PSERVENT;
855 typedef struct servent FAR *LPSERVENT;
856
857 typedef struct protoent PROTOENT;
858 typedef struct protoent *PPROTOENT;
859 typedef struct protoent FAR *LPPROTOENT;
860
861 typedef struct timeval TIMEVAL;
862 typedef struct timeval *PTIMEVAL;
863 typedef struct timeval FAR *LPTIMEVAL;
864
865 /*
866  * Windows message parameter composition and decomposition
867  * macros.
868  *
869  * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
870  * when constructing the response to a WSAAsyncGetXByY() routine.
871  */
872 #define WSAMAKEASYNCREPLY(buflen,error)     MAKELONG(buflen,error)
873 /*
874  * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
875  * when constructing the response to WSAAsyncSelect().
876  */
877 #define WSAMAKESELECTREPLY(event,error)     MAKELONG(event,error)
878 /*
879  * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
880  * to extract the buffer length from the lParam in the response
881  * to a WSAGetXByY().
882  */
883 #define WSAGETASYNCBUFLEN(lParam)           LOWORD(lParam)
884 /*
885  * WSAGETASYNCERROR is intended for use by the Windows Sockets application
886  * to extract the error code from the lParam in the response
887  * to a WSAGetXByY().
888  */
889 #define WSAGETASYNCERROR(lParam)            HIWORD(lParam)
890 /*
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().
894  */
895 #define WSAGETSELECTEVENT(lParam)           LOWORD(lParam)
896 /*
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().
900  */
901 #define WSAGETSELECTERROR(lParam)           HIWORD(lParam)
902
903 #endif  /* _WINSOCKAPI_ */
904
905
906 \1a