|
|
1.1.1.2 root 1: /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
2: *
1.1.1.3 ! root 3: * This header file corresponds to version 1.1 of the Windows Sockets specification.
! 4: *
1.1.1.2 root 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.
1.1.1.3 ! root 9: *
! 10: * Change log:
! 11: *
! 12: * Fri Apr 23 16:31:01 1993 Mark Towfiq ([email protected])
! 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 ([email protected])
! 18: * Fix the IN_CLASSC macro to account for class-D multicasts.
! 19: * Add AF_IPX == AF_NS.
! 20: *
1.1.1.2 root 21: */
22:
1.1 root 23: #ifndef _WINSOCKAPI_
24: #define _WINSOCKAPI_
25:
26: /*
27: * Pull in WINDOWS.H if necessary
28: */
29: #ifndef _INC_WINDOWS
1.1.1.2 root 30: #include <windows.h>
1.1 root 31: #endif /* _INC_WINDOWS */
32:
33: /*
34: * Basic system type definitions, taken from the BSD file sys/types.h.
35: */
1.1.1.2 root 36: typedef unsigned char u_char;
37: typedef unsigned short u_short;
38: typedef unsigned int u_int;
39: typedef unsigned long u_long;
1.1 root 40:
41: /*
42: * The new type to be used in all
43: * instances which refer to sockets.
44: */
1.1.1.2 root 45: typedef u_int SOCKET;
1.1 root 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
1.1.1.2 root 56: #define FD_SETSIZE 64
1.1 root 57: #endif /* FD_SETSIZE */
58:
59: typedef struct fd_set {
1.1.1.3 ! root 60: u_int fd_count; /* how many are SET? */
1.1.1.2 root 61: SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
1.1 root 62: } fd_set;
63:
1.1.1.3 ! root 64: #ifdef __cplusplus
! 65: extern "C" {
! 66: #endif
! 67:
1.1.1.2 root 68: extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
1.1 root 69:
1.1.1.3 ! root 70: #ifdef __cplusplus
! 71: }
! 72: #endif
! 73:
! 74:
! 75: #define FD_CLR(fd, set) do { \
1.1.1.2 root 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) { \
1.1.1.3 ! root 79: while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
1.1.1.2 root 80: ((fd_set FAR *)(set))->fd_array[__i] = \
1.1.1.3 ! root 81: ((fd_set FAR *)(set))->fd_array[__i+1]; \
1.1.1.2 root 82: __i++; \
83: } \
84: ((fd_set FAR *)(set))->fd_count--; \
85: break; \
1.1 root 86: } \
1.1.1.2 root 87: } \
1.1.1.3 ! root 88: } while(0)
1.1 root 89:
1.1.1.3 ! root 90: #define FD_SET(fd, set) do { \
1.1.1.2 root 91: if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \
92: ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=fd;\
1.1.1.3 ! root 93: } while(0)
1.1 root 94:
1.1.1.3 ! root 95: #define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)
1.1 root 96:
1.1.1.3 ! root 97: #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)fd, (fd_set FAR *)set)
1.1 root 98:
99: /*
100: * Structure used in select() call, taken from the BSD file sys/time.h.
101: */
102: struct timeval {
1.1.1.2 root 103: long tv_sec; /* seconds */
104: long tv_usec; /* and microseconds */
1.1 root 105: };
106:
107: /*
108: * Operations on timevals.
109: *
110: * NB: timercmp does not work for >= or <=.
111: */
1.1.1.2 root 112: #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
1.1 root 113: #define timercmp(tvp, uvp, cmp) \
114: ((tvp)->tv_sec cmp (uvp)->tv_sec || \
1.1.1.2 root 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
1.1 root 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: */
1.1.1.2 root 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 */
1.1.1.3 ! root 135: #define _IO(x,y) (IOC_VOID|(x<<8)|y)
1.1.1.2 root 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:
1.1.1.3 ! root 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 */
1.1 root 144:
145: /* Socket I/O Controls */
1.1.1.3 ! root 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? */
1.1 root 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:
1.1.1.2 root 158: struct hostent {
159: char FAR * h_name; /* official name of host */
160: char FAR * FAR * h_aliases; /* alias list */
1.1.1.3 ! root 161: short h_addrtype; /* host address type */
! 162: short h_length; /* length of address */
1.1.1.2 root 163: char FAR * FAR * h_addr_list; /* list of addresses */
164: #define h_addr h_addr_list[0] /* address, for backward compat */
1.1 root 165: };
166:
167: /*
1.1.1.2 root 168: * It is assumed here that a network number
169: * fits in 32 bits.
1.1 root 170: */
171: struct netent {
1.1.1.2 root 172: char FAR * n_name; /* official name of net */
173: char FAR * FAR * n_aliases; /* alias list */
1.1.1.3 ! root 174: short n_addrtype; /* net address type */
1.1.1.2 root 175: u_long n_net; /* network # */
1.1 root 176: };
177:
178: struct servent {
1.1.1.2 root 179: char FAR * s_name; /* official service name */
180: char FAR * FAR * s_aliases; /* alias list */
1.1.1.3 ! root 181: short s_port; /* port # */
1.1.1.2 root 182: char FAR * s_proto; /* protocol to use */
1.1 root 183: };
184:
185: struct protoent {
1.1.1.2 root 186: char FAR * p_name; /* official protocol name */
187: char FAR * FAR * p_aliases; /* alias list */
1.1.1.3 ! root 188: short p_proto; /* protocol # */
1.1 root 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: */
1.1.1.2 root 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 */
1.1 root 207:
1.1.1.2 root 208: #define IPPROTO_RAW 255 /* raw IP packet */
209: #define IPPROTO_MAX 256
1.1 root 210:
211: /*
212: * Port/socket numbers: network standard functions
213: */
1.1.1.2 root 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
1.1 root 226:
227: /*
228: * Port/socket numbers: host specific functions
229: */
1.1.1.2 root 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
1.1 root 235:
236: /*
237: * UNIX TCP sockets
238: */
1.1.1.2 root 239: #define IPPORT_EXECSERVER 512
240: #define IPPORT_LOGINSERVER 513
241: #define IPPORT_CMDSERVER 514
242: #define IPPORT_EFSSERVER 520
1.1 root 243:
244: /*
245: * UNIX UDP sockets
246: */
1.1.1.2 root 247: #define IPPORT_BIFFUDP 512
248: #define IPPORT_WHOSERVER 513
249: #define IPPORT_ROUTESERVER 520
250: /* 520+1 also used */
1.1 root 251:
252: /*
253: * Ports < IPPORT_RESERVED are reserved for
254: * privileged processes (e.g. root).
255: */
1.1.1.2 root 256: #define IPPORT_RESERVED 1024
1.1 root 257:
258: /*
259: * Link numbers
260: */
1.1.1.2 root 261: #define IMPLINK_IP 155
262: #define IMPLINK_LOWEXPER 156
263: #define IMPLINK_HIGHEXPER 158
1.1 root 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;
1.1.1.2 root 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 */
1.1 root 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:
1.1.1.3 ! root 305: #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
1.1 root 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
1.1.1.2 root 311: #define INADDR_LOOPBACK 0x7f000001
1.1.1.3 ! root 312: #define INADDR_BROADCAST (u_long)0xffffffff
! 313: #define INADDR_NONE 0xffffffff
1.1 root 314:
315: /*
316: * Socket address, internet style.
317: */
318: struct sockaddr_in {
1.1.1.2 root 319: short sin_family;
320: u_short sin_port;
321: struct in_addr sin_addr;
322: char sin_zero[8];
1.1 root 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];
1.1.1.3 ! root 333: unsigned short iMaxSockets;
! 334: unsigned short iMaxUdpDg;
1.1.1.2 root 335: char FAR * lpVendorInfo;
1.1 root 336: } WSADATA;
337:
338: typedef WSADATA FAR *LPWSADATA;
339:
340: /*
341: * Options for use with [gs]etsockopt at the IP level.
342: */
1.1.1.2 root 343: #define IP_OPTIONS 1 /* set/get IP per-packet options */
1.1 root 344:
345: /*
346: * Definitions related to sockets: types, address families, options,
347: * taken from the BSD file sys/socket.h.
348: */
349:
350: /*
351: * This is used instead of -1, since the
352: * SOCKET type is unsigned.
353: */
1.1.1.2 root 354: #define INVALID_SOCKET (SOCKET)(~0)
1.1 root 355: #define SOCKET_ERROR (-1)
356:
357: /*
358: * Types
359: */
1.1.1.2 root 360: #define SOCK_STREAM 1 /* stream socket */
361: #define SOCK_DGRAM 2 /* datagram socket */
362: #define SOCK_RAW 3 /* raw-protocol interface */
363: #define SOCK_RDM 4 /* reliably-delivered message */
364: #define SOCK_SEQPACKET 5 /* sequenced packet stream */
1.1 root 365:
366: /*
367: * Option flags per-socket.
368: */
1.1.1.2 root 369: #define SO_DEBUG 0x0001 /* turn on debugging info recording */
370: #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
371: #define SO_REUSEADDR 0x0004 /* allow local address reuse */
372: #define SO_KEEPALIVE 0x0008 /* keep connections alive */
373: #define SO_DONTROUTE 0x0010 /* just use interface addresses */
374: #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
375: #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
376: #define SO_LINGER 0x0080 /* linger on close if data present */
377: #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
1.1 root 378:
1.1.1.2 root 379: #define SO_DONTLINGER (u_int)(~SO_LINGER)
1.1 root 380:
381: /*
382: * Additional options.
383: */
1.1.1.2 root 384: #define SO_SNDBUF 0x1001 /* send buffer size */
385: #define SO_RCVBUF 0x1002 /* receive buffer size */
386: #define SO_SNDLOWAT 0x1003 /* send low-water mark */
387: #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
388: #define SO_SNDTIMEO 0x1005 /* send timeout */
389: #define SO_RCVTIMEO 0x1006 /* receive timeout */
390: #define SO_ERROR 0x1007 /* get error status and clear */
391: #define SO_TYPE 0x1008 /* get socket type */
1.1 root 392:
393: /*
1.1.1.3 ! root 394: * Options for connect and disconnect data and options. Used only by
! 395: * non-TCP/IP transports such as DECNet, OSI TP4, etc.
! 396: */
! 397: #define SO_CONNDATA 0x7000
! 398: #define SO_CONNOPT 0x7001
! 399: #define SO_DISCDATA 0x7002
! 400: #define SO_DISCOPT 0x7003
! 401: #define SO_CONNDATALEN 0x7004
! 402: #define SO_CONNOPTLEN 0x7005
! 403: #define SO_DISCDATALEN 0x7006
! 404: #define SO_DISCOPTLEN 0x7007
! 405:
! 406: /*
! 407: * TCP options.
! 408: */
! 409: #define TCP_NODELAY 0x0001
! 410:
! 411: /*
1.1 root 412: * Address families.
413: */
1.1.1.2 root 414: #define AF_UNSPEC 0 /* unspecified */
415: #define AF_UNIX 1 /* local to host (pipes, portals) */
416: #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
417: #define AF_IMPLINK 3 /* arpanet imp addresses */
418: #define AF_PUP 4 /* pup protocols: e.g. BSP */
419: #define AF_CHAOS 5 /* mit CHAOS protocols */
1.1.1.3 ! root 420: #define AF_IPX 6 /* IPX and SPX */
1.1.1.2 root 421: #define AF_NS 6 /* XEROX NS protocols */
1.1.1.3 ! root 422: #define AF_ISO 7 /* ISO protocols */
! 423: #define AF_OSI AF_ISO /* OSI is ISO */
1.1.1.2 root 424: #define AF_ECMA 8 /* european computer manufacturers */
425: #define AF_DATAKIT 9 /* datakit protocols */
426: #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
427: #define AF_SNA 11 /* IBM SNA */
428: #define AF_DECnet 12 /* DECnet */
429: #define AF_DLI 13 /* Direct data link interface */
430: #define AF_LAT 14 /* LAT */
431: #define AF_HYLINK 15 /* NSC Hyperchannel */
432: #define AF_APPLETALK 16 /* AppleTalk */
1.1.1.3 ! root 433: #define AF_NETBIOS 17 /* NetBios-style addresses */
1.1 root 434:
1.1.1.3 ! root 435: #define AF_MAX 18
1.1 root 436:
437: /*
438: * Structure used by kernel to store most
439: * addresses.
440: */
441: struct sockaddr {
1.1.1.2 root 442: u_short sa_family; /* address family */
443: char sa_data[14]; /* up to 14 bytes of direct address */
1.1 root 444: };
445:
446: /*
447: * Structure used by kernel to pass protocol
448: * information in raw sockets.
449: */
450: struct sockproto {
1.1.1.2 root 451: u_short sp_family; /* address family */
452: u_short sp_protocol; /* protocol */
1.1 root 453: };
454:
455: /*
456: * Protocol families, same as address families for now.
457: */
1.1.1.2 root 458: #define PF_UNSPEC AF_UNSPEC
459: #define PF_UNIX AF_UNIX
460: #define PF_INET AF_INET
461: #define PF_IMPLINK AF_IMPLINK
462: #define PF_PUP AF_PUP
463: #define PF_CHAOS AF_CHAOS
464: #define PF_NS AF_NS
1.1.1.3 ! root 465: #define PF_IPX AF_IPX
! 466: #define PF_ISO AF_ISO
! 467: #define PF_OSI AF_OSI
1.1.1.2 root 468: #define PF_ECMA AF_ECMA
469: #define PF_DATAKIT AF_DATAKIT
470: #define PF_CCITT AF_CCITT
471: #define PF_SNA AF_SNA
472: #define PF_DECnet AF_DECnet
473: #define PF_DLI AF_DLI
474: #define PF_LAT AF_LAT
475: #define PF_HYLINK AF_HYLINK
476: #define PF_APPLETALK AF_APPLETALK
1.1 root 477:
1.1.1.2 root 478: #define PF_MAX AF_MAX
1.1 root 479:
480: /*
481: * Structure used for manipulating linger option.
482: */
483: struct linger {
1.1.1.2 root 484: u_short l_onoff; /* option on/off */
485: u_short l_linger; /* linger time */
1.1 root 486: };
487:
488: /*
489: * Level number for (get/set)sockopt() to apply to socket itself.
490: */
1.1.1.2 root 491: #define SOL_SOCKET 0xffff /* options for socket level */
1.1 root 492:
493: /*
494: * Maximum queue length specifiable by listen.
495: */
1.1.1.2 root 496: #define SOMAXCONN 5
1.1 root 497:
1.1.1.2 root 498: #define MSG_OOB 0x1 /* process out-of-band data */
499: #define MSG_PEEK 0x2 /* peek at incoming message */
500: #define MSG_DONTROUTE 0x4 /* send without using routing tables */
1.1 root 501:
1.1.1.2 root 502: #define MSG_MAXIOVLEN 16
1.1 root 503:
1.1.1.3 ! root 504: #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
! 505:
1.1 root 506: /*
507: * Define constant based on rfc883, used by gethostbyxxxx() calls.
508: */
1.1.1.2 root 509: #define MAXGETHOSTSTRUCT 1024
1.1 root 510:
511: /*
1.1.1.2 root 512: * Define flags to be used with the WSAAsyncSelect() call.
513: */
514: #define FD_READ 0x01
515: #define FD_WRITE 0x02
516: #define FD_OOB 0x04
517: #define FD_ACCEPT 0x08
518: #define FD_CONNECT 0x10
519: #define FD_CLOSE 0x20
520:
521: /*
522: * All Windows Sockets error constants are biased by WSABASEERR from
523: * the "normal"
1.1 root 524: */
525: #define WSABASEERR 10000
526: /*
1.1.1.2 root 527: * Windows Sockets definitions of regular Microsoft C error constants
1.1 root 528: */
529: #define WSAEINTR (WSABASEERR+4)
530: #define WSAEBADF (WSABASEERR+9)
1.1.1.3 ! root 531: #define WSAEACCES (WSABASEERR+13)
1.1 root 532: #define WSAEFAULT (WSABASEERR+14)
533: #define WSAEINVAL (WSABASEERR+22)
534: #define WSAEMFILE (WSABASEERR+24)
535:
536: /*
1.1.1.2 root 537: * Windows Sockets definitions of regular Berkeley error constants
1.1 root 538: */
539: #define WSAEWOULDBLOCK (WSABASEERR+35)
540: #define WSAEINPROGRESS (WSABASEERR+36)
541: #define WSAEALREADY (WSABASEERR+37)
542: #define WSAENOTSOCK (WSABASEERR+38)
543: #define WSAEDESTADDRREQ (WSABASEERR+39)
544: #define WSAEMSGSIZE (WSABASEERR+40)
545: #define WSAEPROTOTYPE (WSABASEERR+41)
546: #define WSAENOPROTOOPT (WSABASEERR+42)
547: #define WSAEPROTONOSUPPORT (WSABASEERR+43)
548: #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
549: #define WSAEOPNOTSUPP (WSABASEERR+45)
550: #define WSAEPFNOSUPPORT (WSABASEERR+46)
551: #define WSAEAFNOSUPPORT (WSABASEERR+47)
552: #define WSAEADDRINUSE (WSABASEERR+48)
553: #define WSAEADDRNOTAVAIL (WSABASEERR+49)
554: #define WSAENETDOWN (WSABASEERR+50)
555: #define WSAENETUNREACH (WSABASEERR+51)
556: #define WSAENETRESET (WSABASEERR+52)
557: #define WSAECONNABORTED (WSABASEERR+53)
558: #define WSAECONNRESET (WSABASEERR+54)
559: #define WSAENOBUFS (WSABASEERR+55)
560: #define WSAEISCONN (WSABASEERR+56)
561: #define WSAENOTCONN (WSABASEERR+57)
562: #define WSAESHUTDOWN (WSABASEERR+58)
563: #define WSAETOOMANYREFS (WSABASEERR+59)
564: #define WSAETIMEDOUT (WSABASEERR+60)
565: #define WSAECONNREFUSED (WSABASEERR+61)
566: #define WSAELOOP (WSABASEERR+62)
567: #define WSAENAMETOOLONG (WSABASEERR+63)
568: #define WSAEHOSTDOWN (WSABASEERR+64)
569: #define WSAEHOSTUNREACH (WSABASEERR+65)
570: #define WSAENOTEMPTY (WSABASEERR+66)
571: #define WSAEPROCLIM (WSABASEERR+67)
572: #define WSAEUSERS (WSABASEERR+68)
573: #define WSAEDQUOT (WSABASEERR+69)
574: #define WSAESTALE (WSABASEERR+70)
575: #define WSAEREMOTE (WSABASEERR+71)
576:
1.1.1.3 ! root 577: #define WSAEDISCON (WSABASEERR+101)
! 578:
1.1 root 579: /*
1.1.1.2 root 580: * Extended Windows Sockets error constant definitions
1.1 root 581: */
582: #define WSASYSNOTREADY (WSABASEERR+91)
583: #define WSAVERNOTSUPPORTED (WSABASEERR+92)
1.1.1.2 root 584: #define WSANOTINITIALISED (WSABASEERR+93)
1.1 root 585:
586: /*
587: * Error return codes from gethostbyname() and gethostbyaddr()
588: * (when using the resolver). Note that these errors are
589: * retrieved via WSAGetLastError() and must therefore follow
590: * the rules for avoiding clashes with error numbers from
591: * specific implementations or language run-time systems.
1.1.1.2 root 592: * For this reason the codes are based at WSABASEERR+1001.
593: * Note also that [WSA]NO_ADDRESS is defined only for
594: * compatibility purposes.
1.1 root 595: */
596:
597: #define h_errno WSAGetLastError()
598:
1.1.1.2 root 599: /* Authoritative Answer: Host not found */
1.1 root 600: #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
601: #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
1.1.1.2 root 602:
603: /* Non-Authoritative: Host not found, or SERVERFAIL */
604: #define WSATRY_AGAIN (WSABASEERR+1002)
1.1 root 605: #define TRY_AGAIN WSATRY_AGAIN
1.1.1.2 root 606:
607: /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
608: #define WSANO_RECOVERY (WSABASEERR+1003)
1.1 root 609: #define NO_RECOVERY WSANO_RECOVERY
1.1.1.2 root 610:
611: /* Valid name, no data record of requested type */
612: #define WSANO_DATA (WSABASEERR+1004)
1.1 root 613: #define NO_DATA WSANO_DATA
1.1.1.2 root 614:
615: /* no address, look for MX record */
616: #define WSANO_ADDRESS WSANO_DATA
1.1 root 617: #define NO_ADDRESS WSANO_ADDRESS
618:
619: /*
1.1.1.3 ! root 620: * Windows Sockets errors redefined as regular Berkeley error constants.
! 621: * These are commented out in Windows NT to avoid conflicts with errno.h.
! 622: * Use the WSA constants instead.
1.1 root 623: */
624: #if 0
625: #define EWOULDBLOCK WSAEWOULDBLOCK
626: #define EINPROGRESS WSAEINPROGRESS
627: #define EALREADY WSAEALREADY
628: #define ENOTSOCK WSAENOTSOCK
629: #define EDESTADDRREQ WSAEDESTADDRREQ
630: #define EMSGSIZE WSAEMSGSIZE
631: #define EPROTOTYPE WSAEPROTOTYPE
632: #define ENOPROTOOPT WSAENOPROTOOPT
633: #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
634: #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
635: #define EOPNOTSUPP WSAEOPNOTSUPP
636: #define EPFNOSUPPORT WSAEPFNOSUPPORT
637: #define EAFNOSUPPORT WSAEAFNOSUPPORT
638: #define EADDRINUSE WSAEADDRINUSE
639: #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
640: #define ENETDOWN WSAENETDOWN
641: #define ENETUNREACH WSAENETUNREACH
642: #define ENETRESET WSAENETRESET
643: #define ECONNABORTED WSAECONNABORTED
644: #define ECONNRESET WSAECONNRESET
645: #define ENOBUFS WSAENOBUFS
646: #define EISCONN WSAEISCONN
647: #define ENOTCONN WSAENOTCONN
648: #define ESHUTDOWN WSAESHUTDOWN
649: #define ETOOMANYREFS WSAETOOMANYREFS
650: #define ETIMEDOUT WSAETIMEDOUT
651: #define ECONNREFUSED WSAECONNREFUSED
652: #define ELOOP WSAELOOP
653: #define ENAMETOOLONG WSAENAMETOOLONG
654: #define EHOSTDOWN WSAEHOSTDOWN
655: #define EHOSTUNREACH WSAEHOSTUNREACH
656: #define ENOTEMPTY WSAENOTEMPTY
657: #define EPROCLIM WSAEPROCLIM
658: #define EUSERS WSAEUSERS
659: #define EDQUOT WSAEDQUOT
660: #define ESTALE WSAESTALE
661: #define EREMOTE WSAEREMOTE
662: #endif
663:
664: /* Socket function prototypes */
665:
1.1.1.3 ! root 666: #ifdef __cplusplus
! 667: extern "C" {
! 668: #endif
! 669:
1.1.1.2 root 670: SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr,
671: int FAR *addrlen);
1.1 root 672:
1.1.1.3 ! root 673: int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *addr, int namelen);
1.1 root 674:
1.1.1.2 root 675: int PASCAL FAR closesocket (SOCKET s);
1.1 root 676:
1.1.1.3 ! root 677: int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
1.1 root 678:
1.1.1.2 root 679: int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp);
1.1 root 680:
1.1.1.2 root 681: int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name,
682: int FAR * namelen);
1.1 root 683:
1.1.1.2 root 684: int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name,
685: int FAR * namelen);
1.1 root 686:
1.1.1.2 root 687: int PASCAL FAR getsockopt (SOCKET s, int level, int optname,
688: char FAR * optval, int FAR *optlen);
1.1 root 689:
1.1.1.2 root 690: u_long PASCAL FAR htonl (u_long hostlong);
1.1 root 691:
1.1.1.2 root 692: u_short PASCAL FAR htons (u_short hostshort);
1.1 root 693:
1.1.1.3 ! root 694: unsigned long PASCAL FAR inet_addr (const char FAR * cp);
1.1 root 695:
1.1.1.2 root 696: char FAR * PASCAL FAR inet_ntoa (struct in_addr in);
1.1 root 697:
1.1.1.2 root 698: int PASCAL FAR listen (SOCKET s, int backlog);
1.1 root 699:
1.1.1.2 root 700: u_long PASCAL FAR ntohl (u_long netlong);
1.1 root 701:
1.1.1.2 root 702: u_short PASCAL FAR ntohs (u_short netshort);
1.1 root 703:
1.1.1.2 root 704: int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags);
1.1 root 705:
1.1.1.2 root 706: int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags,
707: struct sockaddr FAR *from, int FAR * fromlen);
1.1 root 708:
1.1.1.3 ! root 709: int PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set FAR *writefds,
! 710: fd_set FAR *exceptfds, const struct timeval FAR *timeout);
1.1 root 711:
1.1.1.3 ! root 712: int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int flags);
1.1 root 713:
1.1.1.3 ! root 714: int PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, int flags,
! 715: const struct sockaddr FAR *to, int tolen);
1.1 root 716:
1.1.1.2 root 717: int PASCAL FAR setsockopt (SOCKET s, int level, int optname,
1.1.1.3 ! root 718: const char FAR * optval, int optlen);
1.1 root 719:
1.1.1.2 root 720: int PASCAL FAR shutdown (SOCKET s, int how);
1.1 root 721:
1.1.1.2 root 722: SOCKET PASCAL FAR socket (int af, int type, int protocol);
1.1 root 723:
724: /* Database function prototypes */
725:
1.1.1.3 ! root 726: struct hostent FAR * PASCAL FAR gethostbyaddr(const char FAR * addr,
1.1.1.2 root 727: int len, int type);
1.1 root 728:
1.1.1.3 ! root 729: struct hostent FAR * PASCAL FAR gethostbyname(const char FAR * name);
1.1 root 730:
1.1.1.3 ! root 731: int PASCAL FAR gethostname (char FAR * name, int namelen);
1.1 root 732:
1.1.1.3 ! root 733: struct servent FAR * PASCAL FAR getservbyport(int port, const char FAR * proto);
! 734:
! 735: struct servent FAR * PASCAL FAR getservbyname(const char FAR * name,
! 736: const char FAR * proto);
1.1 root 737:
1.1.1.2 root 738: struct protoent FAR * PASCAL FAR getprotobynumber(int proto);
1.1 root 739:
1.1.1.3 ! root 740: struct protoent FAR * PASCAL FAR getprotobyname(const char FAR * name);
1.1 root 741:
742: /* Microsoft Windows Extension function prototypes */
743:
1.1.1.2 root 744: int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
1.1 root 745:
1.1.1.2 root 746: int PASCAL FAR WSACleanup(void);
1.1 root 747:
1.1.1.2 root 748: void PASCAL FAR WSASetLastError(int iError);
1.1 root 749:
1.1.1.2 root 750: int PASCAL FAR WSAGetLastError(void);
1.1 root 751:
1.1.1.2 root 752: BOOL PASCAL FAR WSAIsBlocking(void);
1.1 root 753:
1.1.1.2 root 754: int PASCAL FAR WSAUnhookBlockingHook(void);
1.1 root 755:
1.1.1.2 root 756: FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc);
1.1 root 757:
1.1.1.2 root 758: int PASCAL FAR WSACancelBlockingCall(void);
1.1 root 759:
1.1.1.2 root 760: HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
1.1.1.3 ! root 761: const char FAR * name,
! 762: const char FAR * proto,
1.1.1.2 root 763: char FAR * buf, int buflen);
1.1 root 764:
1.1.1.2 root 765: HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
1.1.1.3 ! root 766: const char FAR * proto, char FAR * buf,
1.1.1.2 root 767: int buflen);
1.1 root 768:
1.1.1.2 root 769: HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
1.1.1.3 ! root 770: const char FAR * name, char FAR * buf,
1.1.1.2 root 771: int buflen);
1.1 root 772:
1.1.1.2 root 773: HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
774: int number, char FAR * buf,
775: int buflen);
1.1 root 776:
1.1.1.2 root 777: HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
1.1.1.3 ! root 778: const char FAR * name, char FAR * buf,
1.1.1.2 root 779: int buflen);
1.1 root 780:
1.1.1.2 root 781: HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
1.1.1.3 ! root 782: const char FAR * addr, int len, int type,
1.1.1.2 root 783: char FAR * buf, int buflen);
1.1 root 784:
1.1.1.2 root 785: int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
1.1 root 786:
1.1.1.2 root 787: int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
788: long lEvent);
1.1 root 789:
1.1.1.3 ! root 790: int PASCAL FAR WSARecvEx (SOCKET s, char FAR * buf, int len, int *flags);
! 791:
! 792: #ifdef __cplusplus
! 793: }
! 794: #endif
! 795:
1.1 root 796: /* Microsoft Windows Extended data types */
797: typedef struct sockaddr SOCKADDR;
798: typedef struct sockaddr *PSOCKADDR;
799: typedef struct sockaddr FAR *LPSOCKADDR;
800:
801: typedef struct sockaddr_in SOCKADDR_IN;
802: typedef struct sockaddr_in *PSOCKADDR_IN;
803: typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
804:
805: typedef struct linger LINGER;
806: typedef struct linger *PLINGER;
807: typedef struct linger FAR *LPLINGER;
808:
809: typedef struct in_addr IN_ADDR;
810: typedef struct in_addr *PIN_ADDR;
811: typedef struct in_addr FAR *LPIN_ADDR;
812:
813: typedef struct fd_set FD_SET;
1.1.1.2 root 814: typedef struct fd_set *PFD_SET;
815: typedef struct fd_set FAR *LPFD_SET;
1.1 root 816:
817: typedef struct hostent HOSTENT;
818: typedef struct hostent *PHOSTENT;
819: typedef struct hostent FAR *LPHOSTENT;
820:
821: typedef struct servent SERVENT;
822: typedef struct servent *PSERVENT;
823: typedef struct servent FAR *LPSERVENT;
824:
825: typedef struct protoent PROTOENT;
826: typedef struct protoent *PPROTOENT;
827: typedef struct protoent FAR *LPPROTOENT;
828:
1.1.1.3 ! root 829: typedef struct timeval TIMEVAL;
! 830: typedef struct timeval *PTIMEVAL;
! 831: typedef struct timeval FAR *LPTIMEVAL;
! 832:
1.1.1.2 root 833: /*
834: * Windows message parameter composition and decomposition
835: * macros.
836: *
837: * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
1.1.1.3 ! root 838: * when constructing the response to a WSAAsyncGetXByY() routine.
1.1.1.2 root 839: */
840: #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
841: /*
842: * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
1.1.1.3 ! root 843: * when constructing the response to WSAAsyncSelect().
1.1.1.2 root 844: */
845: #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
846: /*
847: * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
848: * to extract the buffer length from the lParam in the response
849: * to a WSAGetXByY().
850: */
851: #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
852: /*
853: * WSAGETASYNCERROR is intended for use by the Windows Sockets application
854: * to extract the error code from the lParam in the response
855: * to a WSAGetXByY().
856: */
857: #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
858: /*
859: * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
860: * to extract the event code from the lParam in the response
861: * to a WSAAsyncSelect().
862: */
863: #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
864: /*
865: * WSAGETSELECTERROR is intended for use by the Windows Sockets application
866: * to extract the error code from the lParam in the response
867: * to a WSAAsyncSelect().
868: */
869: #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
1.1 root 870:
1.1.1.2 root 871: #endif /* _WINSOCKAPI_ */
1.1.1.3 ! root 872:
! 873:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.