|
|
1.1.1.2 ! root 1: /* WINSOCK.H--definitions to be used with the WINSOCK.DLL ! 2: * ! 3: * This file includes parts which are Copyright (c) 1982-1986 Regents ! 4: * of the University of California. All rights reserved. The ! 5: * Berkeley Software License Agreement specifies the terms and ! 6: * conditions for redistribution. ! 7: */ ! 8: 1.1 root 9: #ifndef _WINSOCKAPI_ 10: #define _WINSOCKAPI_ 11: 12: /* 13: * Pull in WINDOWS.H if necessary 14: */ 15: #ifndef _INC_WINDOWS 1.1.1.2 ! root 16: #include <windows.h> 1.1 root 17: #endif /* _INC_WINDOWS */ 18: 19: /* 20: * Basic system type definitions, taken from the BSD file sys/types.h. 21: */ 1.1.1.2 ! root 22: typedef unsigned char u_char; ! 23: typedef unsigned short u_short; ! 24: typedef unsigned short ushort; ! 25: typedef unsigned int u_int; ! 26: typedef unsigned long u_long; 1.1 root 27: 28: /* 29: * The new type to be used in all 30: * instances which refer to sockets. 31: */ 1.1.1.2 ! root 32: typedef u_int SOCKET; 1.1 root 33: 34: /* 35: * Select uses arrays of SOCKETs. These macros manipulate such 36: * arrays. FD_SETSIZE may be defined by the user before including 37: * this file, but the default here should be >= 64. 38: * 39: * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE 40: * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE. 41: */ 42: #ifndef FD_SETSIZE 1.1.1.2 ! root 43: #define FD_SETSIZE 64 1.1 root 44: #endif /* FD_SETSIZE */ 45: 46: typedef struct fd_set { 1.1.1.2 ! root 47: u_short fd_count; /* how many are SET? */ ! 48: SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */ 1.1 root 49: } fd_set; 50: 1.1.1.2 ! root 51: extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *); 1.1 root 52: 53: #define FD_CLR(fd, set) { \ 1.1.1.2 ! root 54: u_int __i; \ ! 55: for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \ ! 56: if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \ ! 57: while (__i < (u_int)(((fd_set FAR *)(set))->fd_count-1)) { \ ! 58: ((fd_set FAR *)(set))->fd_array[__i] = \ ! 59: ((fd_set FAR*)(set))->fd_array[__i+1]; \ ! 60: __i++; \ ! 61: } \ ! 62: ((fd_set FAR *)(set))->fd_count--; \ ! 63: break; \ 1.1 root 64: } \ 1.1.1.2 ! root 65: } \ 1.1 root 66: } 67: 68: #define FD_SET(fd, set) { \ 1.1.1.2 ! root 69: if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \ ! 70: ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=fd;\ ! 71: } 1.1 root 72: 73: #define FD_ZERO(set) ((fd_set FAR *)(set))->fd_count=0 74: 75: #define FD_ISSET(fd, set) __WSAFDIsSet((int)fd, (fd_set FAR *)set) 76: 77: /* 78: * Structure used in select() call, taken from the BSD file sys/time.h. 79: */ 80: struct timeval { 1.1.1.2 ! root 81: long tv_sec; /* seconds */ ! 82: long tv_usec; /* and microseconds */ 1.1 root 83: }; 84: 85: /* 86: * Operations on timevals. 87: * 88: * NB: timercmp does not work for >= or <=. 89: */ 1.1.1.2 ! root 90: #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 1.1 root 91: #define timercmp(tvp, uvp, cmp) \ 92: ((tvp)->tv_sec cmp (uvp)->tv_sec || \ 1.1.1.2 ! root 93: (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) ! 94: #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 1.1 root 95: 96: /* 97: * Commands for ioctlsocket(), taken from the BSD file fcntl.h. 98: * 99: * 100: * Ioctl's have the command encoded in the lower word, 101: * and the size of any in or out parameters in the upper 102: * word. The high 2 bits of the upper word are used 103: * to encode the in/out status of the parameter; for now 104: * we restrict parameters to at most 128 bytes. 105: */ 1.1.1.2 ! root 106: #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ ! 107: #define IOC_VOID 0x20000000 /* no parameters */ ! 108: #define IOC_OUT 0x40000000 /* copy out parameters */ ! 109: #define IOC_IN 0x80000000 /* copy in parameters */ ! 110: #define IOC_INOUT (IOC_IN|IOC_OUT) ! 111: /* 0x20000000 distinguishes new & ! 112: old ioctl's */ ! 113: #define _IO(x,y) (IOC_VOID|('x'<<8)|y) ! 114: ! 115: #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) ! 116: ! 117: #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) ! 118: ! 119: #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ ! 120: #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ ! 121: #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ 1.1 root 122: 123: /* Socket I/O Controls */ 1.1.1.2 ! root 124: #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ ! 125: #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ ! 126: #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ ! 127: #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ ! 128: #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ 1.1 root 129: 130: /* 131: * Structures returned by network data base library, taken from the 132: * BSD file netdb.h. All addresses are supplied in host order, and 133: * returned in network order (suitable for use in system calls). 134: */ 135: 1.1.1.2 ! root 136: struct hostent { ! 137: char FAR * h_name; /* official name of host */ ! 138: char FAR * FAR * h_aliases; /* alias list */ ! 139: int h_addrtype; /* host address type */ ! 140: int h_length; /* length of address */ ! 141: char FAR * FAR * h_addr_list; /* list of addresses */ ! 142: #define h_addr h_addr_list[0] /* address, for backward compat */ 1.1 root 143: }; 144: 145: /* 1.1.1.2 ! root 146: * It is assumed here that a network number ! 147: * fits in 32 bits. 1.1 root 148: */ 149: struct netent { 1.1.1.2 ! root 150: char FAR * n_name; /* official name of net */ ! 151: char FAR * FAR * n_aliases; /* alias list */ ! 152: int n_addrtype; /* net address type */ ! 153: u_long n_net; /* network # */ 1.1 root 154: }; 155: 156: struct servent { 1.1.1.2 ! root 157: char FAR * s_name; /* official service name */ ! 158: char FAR * FAR * s_aliases; /* alias list */ ! 159: int s_port; /* port # */ ! 160: char FAR * s_proto; /* protocol to use */ 1.1 root 161: }; 162: 163: struct protoent { 1.1.1.2 ! root 164: char FAR * p_name; /* official protocol name */ ! 165: char FAR * FAR * p_aliases; /* alias list */ ! 166: int p_proto; /* protocol # */ 1.1 root 167: }; 168: 169: /* 170: * Constants and structures defined by the internet system, 171: * Per RFC 790, September 1981, taken from the BSD file netinet/in.h. 172: */ 173: 174: /* 175: * Protocols 176: */ 1.1.1.2 ! root 177: #define IPPROTO_IP 0 /* dummy for IP */ ! 178: #define IPPROTO_ICMP 1 /* control message protocol */ ! 179: #define IPPROTO_GGP 2 /* gateway^2 (deprecated) */ ! 180: #define IPPROTO_TCP 6 /* tcp */ ! 181: #define IPPROTO_PUP 12 /* pup */ ! 182: #define IPPROTO_UDP 17 /* user datagram protocol */ ! 183: #define IPPROTO_IDP 22 /* xns idp */ ! 184: #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ 1.1 root 185: 1.1.1.2 ! root 186: #define IPPROTO_RAW 255 /* raw IP packet */ ! 187: #define IPPROTO_MAX 256 1.1 root 188: 189: /* 190: * Port/socket numbers: network standard functions 191: */ 1.1.1.2 ! root 192: #define IPPORT_ECHO 7 ! 193: #define IPPORT_DISCARD 9 ! 194: #define IPPORT_SYSTAT 11 ! 195: #define IPPORT_DAYTIME 13 ! 196: #define IPPORT_NETSTAT 15 ! 197: #define IPPORT_FTP 21 ! 198: #define IPPORT_TELNET 23 ! 199: #define IPPORT_SMTP 25 ! 200: #define IPPORT_TIMESERVER 37 ! 201: #define IPPORT_NAMESERVER 42 ! 202: #define IPPORT_WHOIS 43 ! 203: #define IPPORT_MTP 57 1.1 root 204: 205: /* 206: * Port/socket numbers: host specific functions 207: */ 1.1.1.2 ! root 208: #define IPPORT_TFTP 69 ! 209: #define IPPORT_RJE 77 ! 210: #define IPPORT_FINGER 79 ! 211: #define IPPORT_TTYLINK 87 ! 212: #define IPPORT_SUPDUP 95 1.1 root 213: 214: /* 215: * UNIX TCP sockets 216: */ 1.1.1.2 ! root 217: #define IPPORT_EXECSERVER 512 ! 218: #define IPPORT_LOGINSERVER 513 ! 219: #define IPPORT_CMDSERVER 514 ! 220: #define IPPORT_EFSSERVER 520 1.1 root 221: 222: /* 223: * UNIX UDP sockets 224: */ 1.1.1.2 ! root 225: #define IPPORT_BIFFUDP 512 ! 226: #define IPPORT_WHOSERVER 513 ! 227: #define IPPORT_ROUTESERVER 520 ! 228: /* 520+1 also used */ 1.1 root 229: 230: /* 231: * Ports < IPPORT_RESERVED are reserved for 232: * privileged processes (e.g. root). 233: */ 1.1.1.2 ! root 234: #define IPPORT_RESERVED 1024 1.1 root 235: 236: /* 237: * Link numbers 238: */ 1.1.1.2 ! root 239: #define IMPLINK_IP 155 ! 240: #define IMPLINK_LOWEXPER 156 ! 241: #define IMPLINK_HIGHEXPER 158 1.1 root 242: 243: /* 244: * Internet address (old style... should be updated) 245: */ 246: struct in_addr { 247: union { 248: struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; 249: struct { u_short s_w1,s_w2; } S_un_w; 250: u_long S_addr; 251: } S_un; 1.1.1.2 ! root 252: #define s_addr S_un.S_addr ! 253: /* can be used for most tcp & ip code */ ! 254: #define s_host S_un.S_un_b.s_b2 ! 255: /* host on imp */ ! 256: #define s_net S_un.S_un_b.s_b1 ! 257: /* network */ ! 258: #define s_imp S_un.S_un_w.s_w2 ! 259: /* imp */ ! 260: #define s_impno S_un.S_un_b.s_b4 ! 261: /* imp # */ ! 262: #define s_lh S_un.S_un_b.s_b3 ! 263: /* logical host */ 1.1 root 264: }; 265: 266: /* 267: * Definitions of bits in internet address integers. 268: * On subnets, the decomposition of addresses to host and net parts 269: * is done according to subnet mask, not the masks here. 270: */ 271: #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) 272: #define IN_CLASSA_NET 0xff000000 273: #define IN_CLASSA_NSHIFT 24 274: #define IN_CLASSA_HOST 0x00ffffff 275: #define IN_CLASSA_MAX 128 276: 277: #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) 278: #define IN_CLASSB_NET 0xffff0000 279: #define IN_CLASSB_NSHIFT 16 280: #define IN_CLASSB_HOST 0x0000ffff 281: #define IN_CLASSB_MAX 65536 282: 283: #define IN_CLASSC(i) (((long)(i) & 0xc0000000) == 0xc0000000) 284: #define IN_CLASSC_NET 0xffffff00 285: #define IN_CLASSC_NSHIFT 8 286: #define IN_CLASSC_HOST 0x000000ff 287: 288: #define INADDR_ANY (u_long)0x00000000 1.1.1.2 ! root 289: #define INADDR_LOOPBACK 0x7f000001 1.1 root 290: #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ 1.1.1.2 ! root 291: #define INADDR_NONE 0xffffffff /* -1 return */ 1.1 root 292: 293: /* 294: * Socket address, internet style. 295: */ 296: struct sockaddr_in { 1.1.1.2 ! root 297: short sin_family; ! 298: u_short sin_port; ! 299: struct in_addr sin_addr; ! 300: char sin_zero[8]; 1.1 root 301: }; 302: 303: #define WSADESCRIPTION_LEN 256 304: #define WSASYS_STATUS_LEN 128 305: 306: typedef struct WSAData { 307: WORD wVersion; 308: WORD wHighVersion; 309: char szDescription[WSADESCRIPTION_LEN+1]; 310: char szSystemStatus[WSASYS_STATUS_LEN+1]; 311: int iMaxSockets; 312: int iMaxUdpDg; 1.1.1.2 ! root 313: char FAR * lpVendorInfo; 1.1 root 314: } WSADATA; 315: 316: typedef WSADATA FAR *LPWSADATA; 317: 318: /* 319: * Options for use with [gs]etsockopt at the IP level. 320: */ 1.1.1.2 ! root 321: #define IP_OPTIONS 1 /* set/get IP per-packet options */ 1.1 root 322: 323: /* 324: * Definitions related to sockets: types, address families, options, 325: * taken from the BSD file sys/socket.h. 326: */ 327: 328: /* 329: * This is used instead of -1, since the 330: * SOCKET type is unsigned. 331: */ 1.1.1.2 ! root 332: #define INVALID_SOCKET (SOCKET)(~0) 1.1 root 333: #define SOCKET_ERROR (-1) 334: 335: /* 336: * Types 337: */ 1.1.1.2 ! root 338: #define SOCK_STREAM 1 /* stream socket */ ! 339: #define SOCK_DGRAM 2 /* datagram socket */ ! 340: #define SOCK_RAW 3 /* raw-protocol interface */ ! 341: #define SOCK_RDM 4 /* reliably-delivered message */ ! 342: #define SOCK_SEQPACKET 5 /* sequenced packet stream */ 1.1 root 343: 344: /* 345: * Option flags per-socket. 346: */ 1.1.1.2 ! root 347: #define SO_DEBUG 0x0001 /* turn on debugging info recording */ ! 348: #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ ! 349: #define SO_REUSEADDR 0x0004 /* allow local address reuse */ ! 350: #define SO_KEEPALIVE 0x0008 /* keep connections alive */ ! 351: #define SO_DONTROUTE 0x0010 /* just use interface addresses */ ! 352: #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ ! 353: #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ ! 354: #define SO_LINGER 0x0080 /* linger on close if data present */ ! 355: #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 1.1 root 356: 1.1.1.2 ! root 357: #define SO_DONTLINGER (u_int)(~SO_LINGER) 1.1 root 358: 359: /* 360: * Additional options. 361: */ 1.1.1.2 ! root 362: #define SO_SNDBUF 0x1001 /* send buffer size */ ! 363: #define SO_RCVBUF 0x1002 /* receive buffer size */ ! 364: #define SO_SNDLOWAT 0x1003 /* send low-water mark */ ! 365: #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ ! 366: #define SO_SNDTIMEO 0x1005 /* send timeout */ ! 367: #define SO_RCVTIMEO 0x1006 /* receive timeout */ ! 368: #define SO_ERROR 0x1007 /* get error status and clear */ ! 369: #define SO_TYPE 0x1008 /* get socket type */ 1.1 root 370: 371: /* 372: * Address families. 373: */ 1.1.1.2 ! root 374: #define AF_UNSPEC 0 /* unspecified */ ! 375: #define AF_UNIX 1 /* local to host (pipes, portals) */ ! 376: #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ ! 377: #define AF_IMPLINK 3 /* arpanet imp addresses */ ! 378: #define AF_PUP 4 /* pup protocols: e.g. BSP */ ! 379: #define AF_CHAOS 5 /* mit CHAOS protocols */ ! 380: #define AF_NS 6 /* XEROX NS protocols */ ! 381: #define AF_NBS 7 /* nbs protocols */ ! 382: #define AF_ECMA 8 /* european computer manufacturers */ ! 383: #define AF_DATAKIT 9 /* datakit protocols */ ! 384: #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ ! 385: #define AF_SNA 11 /* IBM SNA */ ! 386: #define AF_DECnet 12 /* DECnet */ ! 387: #define AF_DLI 13 /* Direct data link interface */ ! 388: #define AF_LAT 14 /* LAT */ ! 389: #define AF_HYLINK 15 /* NSC Hyperchannel */ ! 390: #define AF_APPLETALK 16 /* AppleTalk */ 1.1 root 391: 1.1.1.2 ! root 392: #define AF_MAX 17 1.1 root 393: 394: /* 395: * Structure used by kernel to store most 396: * addresses. 397: */ 398: struct sockaddr { 1.1.1.2 ! root 399: u_short sa_family; /* address family */ ! 400: char sa_data[14]; /* up to 14 bytes of direct address */ 1.1 root 401: }; 402: 403: /* 404: * Structure used by kernel to pass protocol 405: * information in raw sockets. 406: */ 407: struct sockproto { 1.1.1.2 ! root 408: u_short sp_family; /* address family */ ! 409: u_short sp_protocol; /* protocol */ 1.1 root 410: }; 411: 412: /* 413: * Protocol families, same as address families for now. 414: */ 1.1.1.2 ! root 415: #define PF_UNSPEC AF_UNSPEC ! 416: #define PF_UNIX AF_UNIX ! 417: #define PF_INET AF_INET ! 418: #define PF_IMPLINK AF_IMPLINK ! 419: #define PF_PUP AF_PUP ! 420: #define PF_CHAOS AF_CHAOS ! 421: #define PF_NS AF_NS ! 422: #define PF_NBS AF_NBS ! 423: #define PF_ECMA AF_ECMA ! 424: #define PF_DATAKIT AF_DATAKIT ! 425: #define PF_CCITT AF_CCITT ! 426: #define PF_SNA AF_SNA ! 427: #define PF_DECnet AF_DECnet ! 428: #define PF_DLI AF_DLI ! 429: #define PF_LAT AF_LAT ! 430: #define PF_HYLINK AF_HYLINK ! 431: #define PF_APPLETALK AF_APPLETALK 1.1 root 432: 1.1.1.2 ! root 433: #define PF_MAX AF_MAX 1.1 root 434: 435: /* 436: * Structure used for manipulating linger option. 437: */ 438: struct linger { 1.1.1.2 ! root 439: u_short l_onoff; /* option on/off */ ! 440: u_short l_linger; /* linger time */ 1.1 root 441: }; 442: 443: /* 444: * Level number for (get/set)sockopt() to apply to socket itself. 445: */ 1.1.1.2 ! root 446: #define SOL_SOCKET 0xffff /* options for socket level */ 1.1 root 447: 448: /* 449: * Maximum queue length specifiable by listen. 450: */ 1.1.1.2 ! root 451: #define SOMAXCONN 5 1.1 root 452: 1.1.1.2 ! root 453: #define MSG_OOB 0x1 /* process out-of-band data */ ! 454: #define MSG_PEEK 0x2 /* peek at incoming message */ ! 455: #define MSG_DONTROUTE 0x4 /* send without using routing tables */ 1.1 root 456: 1.1.1.2 ! root 457: #define MSG_MAXIOVLEN 16 1.1 root 458: 459: /* 460: * Define constant based on rfc883, used by gethostbyxxxx() calls. 461: */ 1.1.1.2 ! root 462: #define MAXGETHOSTSTRUCT 1024 1.1 root 463: 464: /* 1.1.1.2 ! root 465: * Define flags to be used with the WSAAsyncSelect() call. ! 466: */ ! 467: #define FD_READ 0x01 ! 468: #define FD_WRITE 0x02 ! 469: #define FD_OOB 0x04 ! 470: #define FD_ACCEPT 0x08 ! 471: #define FD_CONNECT 0x10 ! 472: #define FD_CLOSE 0x20 ! 473: ! 474: /* ! 475: * All Windows Sockets error constants are biased by WSABASEERR from ! 476: * the "normal" 1.1 root 477: */ 478: #define WSABASEERR 10000 479: /* 1.1.1.2 ! root 480: * Windows Sockets definitions of regular Microsoft C error constants 1.1 root 481: */ 482: #define WSAEINTR (WSABASEERR+4) 483: #define WSAEBADF (WSABASEERR+9) 484: #define WSAEFAULT (WSABASEERR+14) 485: #define WSAEINVAL (WSABASEERR+22) 486: #define WSAEMFILE (WSABASEERR+24) 487: 488: /* 1.1.1.2 ! root 489: * Windows Sockets definitions of regular Berkeley error constants 1.1 root 490: */ 491: #define WSAEWOULDBLOCK (WSABASEERR+35) 492: #define WSAEINPROGRESS (WSABASEERR+36) 493: #define WSAEALREADY (WSABASEERR+37) 494: #define WSAENOTSOCK (WSABASEERR+38) 495: #define WSAEDESTADDRREQ (WSABASEERR+39) 496: #define WSAEMSGSIZE (WSABASEERR+40) 497: #define WSAEPROTOTYPE (WSABASEERR+41) 498: #define WSAENOPROTOOPT (WSABASEERR+42) 499: #define WSAEPROTONOSUPPORT (WSABASEERR+43) 500: #define WSAESOCKTNOSUPPORT (WSABASEERR+44) 501: #define WSAEOPNOTSUPP (WSABASEERR+45) 502: #define WSAEPFNOSUPPORT (WSABASEERR+46) 503: #define WSAEAFNOSUPPORT (WSABASEERR+47) 504: #define WSAEADDRINUSE (WSABASEERR+48) 505: #define WSAEADDRNOTAVAIL (WSABASEERR+49) 506: #define WSAENETDOWN (WSABASEERR+50) 507: #define WSAENETUNREACH (WSABASEERR+51) 508: #define WSAENETRESET (WSABASEERR+52) 509: #define WSAECONNABORTED (WSABASEERR+53) 510: #define WSAECONNRESET (WSABASEERR+54) 511: #define WSAENOBUFS (WSABASEERR+55) 512: #define WSAEISCONN (WSABASEERR+56) 513: #define WSAENOTCONN (WSABASEERR+57) 514: #define WSAESHUTDOWN (WSABASEERR+58) 515: #define WSAETOOMANYREFS (WSABASEERR+59) 516: #define WSAETIMEDOUT (WSABASEERR+60) 517: #define WSAECONNREFUSED (WSABASEERR+61) 518: #define WSAELOOP (WSABASEERR+62) 519: #define WSAENAMETOOLONG (WSABASEERR+63) 520: #define WSAEHOSTDOWN (WSABASEERR+64) 521: #define WSAEHOSTUNREACH (WSABASEERR+65) 522: #define WSAENOTEMPTY (WSABASEERR+66) 523: #define WSAEPROCLIM (WSABASEERR+67) 524: #define WSAEUSERS (WSABASEERR+68) 525: #define WSAEDQUOT (WSABASEERR+69) 526: #define WSAESTALE (WSABASEERR+70) 527: #define WSAEREMOTE (WSABASEERR+71) 528: 529: /* 1.1.1.2 ! root 530: * Extended Windows Sockets error constant definitions 1.1 root 531: */ 532: #define WSASYSNOTREADY (WSABASEERR+91) 533: #define WSAVERNOTSUPPORTED (WSABASEERR+92) 1.1.1.2 ! root 534: #define WSANOTINITIALISED (WSABASEERR+93) 1.1 root 535: 536: /* 537: * Error return codes from gethostbyname() and gethostbyaddr() 538: * (when using the resolver). Note that these errors are 539: * retrieved via WSAGetLastError() and must therefore follow 540: * the rules for avoiding clashes with error numbers from 541: * specific implementations or language run-time systems. 1.1.1.2 ! root 542: * For this reason the codes are based at WSABASEERR+1001. ! 543: * Note also that [WSA]NO_ADDRESS is defined only for ! 544: * compatibility purposes. 1.1 root 545: */ 546: 547: #define h_errno WSAGetLastError() 548: 1.1.1.2 ! root 549: /* Authoritative Answer: Host not found */ 1.1 root 550: #define WSAHOST_NOT_FOUND (WSABASEERR+1001) 551: #define HOST_NOT_FOUND WSAHOST_NOT_FOUND 1.1.1.2 ! root 552: ! 553: /* Non-Authoritative: Host not found, or SERVERFAIL */ ! 554: #define WSATRY_AGAIN (WSABASEERR+1002) 1.1 root 555: #define TRY_AGAIN WSATRY_AGAIN 1.1.1.2 ! root 556: ! 557: /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ ! 558: #define WSANO_RECOVERY (WSABASEERR+1003) 1.1 root 559: #define NO_RECOVERY WSANO_RECOVERY 1.1.1.2 ! root 560: ! 561: /* Valid name, no data record of requested type */ ! 562: #define WSANO_DATA (WSABASEERR+1004) 1.1 root 563: #define NO_DATA WSANO_DATA 1.1.1.2 ! root 564: ! 565: /* no address, look for MX record */ ! 566: #define WSANO_ADDRESS WSANO_DATA 1.1 root 567: #define NO_ADDRESS WSANO_ADDRESS 568: 569: /* 1.1.1.2 ! root 570: * Windows Sockets errors redefined as regular Berkeley error constants 1.1 root 571: */ 572: #if 0 573: #define EWOULDBLOCK WSAEWOULDBLOCK 574: #define EINPROGRESS WSAEINPROGRESS 575: #define EALREADY WSAEALREADY 576: #define ENOTSOCK WSAENOTSOCK 577: #define EDESTADDRREQ WSAEDESTADDRREQ 578: #define EMSGSIZE WSAEMSGSIZE 579: #define EPROTOTYPE WSAEPROTOTYPE 580: #define ENOPROTOOPT WSAENOPROTOOPT 581: #define EPROTONOSUPPORT WSAEPROTONOSUPPORT 582: #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT 583: #define EOPNOTSUPP WSAEOPNOTSUPP 584: #define EPFNOSUPPORT WSAEPFNOSUPPORT 585: #define EAFNOSUPPORT WSAEAFNOSUPPORT 586: #define EADDRINUSE WSAEADDRINUSE 587: #define EADDRNOTAVAIL WSAEADDRNOTAVAIL 588: #define ENETDOWN WSAENETDOWN 589: #define ENETUNREACH WSAENETUNREACH 590: #define ENETRESET WSAENETRESET 591: #define ECONNABORTED WSAECONNABORTED 592: #define ECONNRESET WSAECONNRESET 593: #define ENOBUFS WSAENOBUFS 594: #define EISCONN WSAEISCONN 595: #define ENOTCONN WSAENOTCONN 596: #define ESHUTDOWN WSAESHUTDOWN 597: #define ETOOMANYREFS WSAETOOMANYREFS 598: #define ETIMEDOUT WSAETIMEDOUT 599: #define ECONNREFUSED WSAECONNREFUSED 600: #define ELOOP WSAELOOP 601: #define ENAMETOOLONG WSAENAMETOOLONG 602: #define EHOSTDOWN WSAEHOSTDOWN 603: #define EHOSTUNREACH WSAEHOSTUNREACH 604: #define ENOTEMPTY WSAENOTEMPTY 605: #define EPROCLIM WSAEPROCLIM 606: #define EUSERS WSAEUSERS 607: #define EDQUOT WSAEDQUOT 608: #define ESTALE WSAESTALE 609: #define EREMOTE WSAEREMOTE 610: #endif 611: 612: /* Socket function prototypes */ 613: 1.1.1.2 ! root 614: SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr, ! 615: int FAR *addrlen); 1.1 root 616: 1.1.1.2 ! root 617: int PASCAL FAR bind (SOCKET s, struct sockaddr FAR *addr, int namelen); 1.1 root 618: 1.1.1.2 ! root 619: int PASCAL FAR closesocket (SOCKET s); 1.1 root 620: 1.1.1.2 ! root 621: int PASCAL FAR connect (SOCKET s, struct sockaddr FAR *name, int namelen); 1.1 root 622: 1.1.1.2 ! root 623: int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp); 1.1 root 624: 1.1.1.2 ! root 625: int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name, ! 626: int FAR * namelen); 1.1 root 627: 1.1.1.2 ! root 628: int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name, ! 629: int FAR * namelen); 1.1 root 630: 1.1.1.2 ! root 631: int PASCAL FAR getsockopt (SOCKET s, int level, int optname, ! 632: char FAR * optval, int FAR *optlen); 1.1 root 633: 1.1.1.2 ! root 634: u_long PASCAL FAR htonl (u_long hostlong); 1.1 root 635: 1.1.1.2 ! root 636: u_short PASCAL FAR htons (u_short hostshort); 1.1 root 637: 638: #if 0 1.1.1.2 ! root 639: struct in_addr PASCAL FAR inet_addr (char FAR * cp); 1.1 root 640: #else 641: unsigned long PASCAL inet_addr (char FAR *cp); 642: #endif 643: 1.1.1.2 ! root 644: char FAR * PASCAL FAR inet_ntoa (struct in_addr in); 1.1 root 645: 1.1.1.2 ! root 646: int PASCAL FAR listen (SOCKET s, int backlog); 1.1 root 647: 1.1.1.2 ! root 648: u_long PASCAL FAR ntohl (u_long netlong); 1.1 root 649: 1.1.1.2 ! root 650: u_short PASCAL FAR ntohs (u_short netshort); 1.1 root 651: 1.1.1.2 ! root 652: int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags); 1.1 root 653: 1.1.1.2 ! root 654: int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags, ! 655: struct sockaddr FAR *from, int FAR * fromlen); 1.1 root 656: 1.1.1.2 ! root 657: long PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set far *writefds, 1.1 root 658: fd_set FAR *exceptfds, struct timeval far *timeout); 659: 1.1.1.2 ! root 660: int PASCAL FAR send (SOCKET s, char FAR * buf, int len, int flags); 1.1 root 661: 1.1.1.2 ! root 662: int PASCAL FAR sendto (SOCKET s, char FAR * buf, int len, int flags, ! 663: struct sockaddr FAR *to, int tolen); 1.1 root 664: 1.1.1.2 ! root 665: int PASCAL FAR setsockopt (SOCKET s, int level, int optname, ! 666: char FAR * optval, int optlen); 1.1 root 667: 1.1.1.2 ! root 668: int PASCAL FAR shutdown (SOCKET s, int how); 1.1 root 669: 1.1.1.2 ! root 670: SOCKET PASCAL FAR socket (int af, int type, int protocol); 1.1 root 671: 672: /* Database function prototypes */ 673: 1.1.1.2 ! root 674: struct hostent FAR * PASCAL FAR gethostbyaddr(char FAR * addr, ! 675: int len, int type); 1.1 root 676: 1.1.1.2 ! root 677: struct hostent FAR * PASCAL FAR gethostbyname(char FAR * name); 1.1 root 678: 1.1.1.2 ! root 679: struct servent FAR * PASCAL FAR getservbyport(int port, char FAR * proto); 1.1 root 680: 1.1.1.2 ! root 681: struct servent FAR * PASCAL FAR getservbyname(char FAR * name, ! 682: char FAR * proto); 1.1 root 683: 1.1.1.2 ! root 684: struct protoent FAR * PASCAL FAR getprotobynumber(int proto); 1.1 root 685: 1.1.1.2 ! root 686: struct protoent FAR * PASCAL FAR getprotobyname(char FAR * name); 1.1 root 687: 688: /* Microsoft Windows Extension function prototypes */ 689: 1.1.1.2 ! root 690: int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); 1.1 root 691: 1.1.1.2 ! root 692: int PASCAL FAR WSACleanup(void); 1.1 root 693: 1.1.1.2 ! root 694: void PASCAL FAR WSASetLastError(int iError); 1.1 root 695: 1.1.1.2 ! root 696: int PASCAL FAR WSAGetLastError(void); 1.1 root 697: 1.1.1.2 ! root 698: BOOL PASCAL FAR WSAIsBlocking(void); 1.1 root 699: 1.1.1.2 ! root 700: int PASCAL FAR WSAUnhookBlockingHook(void); 1.1 root 701: 1.1.1.2 ! root 702: FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc); 1.1 root 703: 1.1.1.2 ! root 704: int PASCAL FAR WSACancelBlockingCall(void); 1.1 root 705: 1.1.1.2 ! root 706: HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg, ! 707: char FAR * name, char FAR * proto, ! 708: char FAR * buf, int buflen); 1.1 root 709: 1.1.1.2 ! root 710: HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, ! 711: char FAR * proto, char FAR * buf, ! 712: int buflen); 1.1 root 713: 1.1.1.2 ! root 714: HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, ! 715: char FAR * name, char FAR * buf, ! 716: int buflen); 1.1 root 717: 1.1.1.2 ! root 718: HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, ! 719: int number, char FAR * buf, ! 720: int buflen); 1.1 root 721: 1.1.1.2 ! root 722: HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, ! 723: char FAR * name, char FAR * buf, ! 724: int buflen); 1.1 root 725: 1.1.1.2 ! root 726: HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, ! 727: char FAR * addr, int len, int type, ! 728: char FAR * buf, int buflen); 1.1 root 729: 1.1.1.2 ! root 730: int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle); 1.1 root 731: 1.1.1.2 ! root 732: int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, ! 733: long lEvent); 1.1 root 734: 735: /* Microsoft Windows Extended data types */ 736: typedef struct sockaddr SOCKADDR; 737: typedef struct sockaddr *PSOCKADDR; 738: typedef struct sockaddr FAR *LPSOCKADDR; 739: 740: typedef struct sockaddr_in SOCKADDR_IN; 741: typedef struct sockaddr_in *PSOCKADDR_IN; 742: typedef struct sockaddr_in FAR *LPSOCKADDR_IN; 743: 744: typedef struct linger LINGER; 745: typedef struct linger *PLINGER; 746: typedef struct linger FAR *LPLINGER; 747: 748: typedef struct in_addr IN_ADDR; 749: typedef struct in_addr *PIN_ADDR; 750: typedef struct in_addr FAR *LPIN_ADDR; 751: 752: typedef struct fd_set FD_SET; 1.1.1.2 ! root 753: typedef struct fd_set *PFD_SET; ! 754: typedef struct fd_set FAR *LPFD_SET; 1.1 root 755: 756: typedef struct hostent HOSTENT; 757: typedef struct hostent *PHOSTENT; 758: typedef struct hostent FAR *LPHOSTENT; 759: 760: typedef struct servent SERVENT; 761: typedef struct servent *PSERVENT; 762: typedef struct servent FAR *LPSERVENT; 763: 764: typedef struct protoent PROTOENT; 765: typedef struct protoent *PPROTOENT; 766: typedef struct protoent FAR *LPPROTOENT; 767: 1.1.1.2 ! root 768: /* ! 769: * Windows message parameter composition and decomposition ! 770: * macros. ! 771: * ! 772: * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation ! 773: * when constructing the response to a WSAGetXByY() ! 774: */ ! 775: #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error) ! 776: /* ! 777: * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation ! 778: * when constructing the response to WSAAsyncSelect() ! 779: */ ! 780: #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error) ! 781: /* ! 782: * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application ! 783: * to extract the buffer length from the lParam in the response ! 784: * to a WSAGetXByY(). ! 785: */ ! 786: #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam) ! 787: /* ! 788: * WSAGETASYNCERROR is intended for use by the Windows Sockets application ! 789: * to extract the error code from the lParam in the response ! 790: * to a WSAGetXByY(). ! 791: */ ! 792: #define WSAGETASYNCERROR(lParam) HIWORD(lParam) ! 793: /* ! 794: * WSAGETSELECTEVENT is intended for use by the Windows Sockets application ! 795: * to extract the event code from the lParam in the response ! 796: * to a WSAAsyncSelect(). ! 797: */ ! 798: #define WSAGETSELECTEVENT(lParam) LOWORD(lParam) ! 799: /* ! 800: * WSAGETSELECTERROR is intended for use by the Windows Sockets application ! 801: * to extract the error code from the lParam in the response ! 802: * to a WSAAsyncSelect(). ! 803: */ ! 804: #define WSAGETSELECTERROR(lParam) HIWORD(lParam) 1.1 root 805: 1.1.1.2 ! root 806: #endif /* _WINSOCKAPI_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.