home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / AutoPC / apcsdk10.exe / data1.cab / Emulation_Include_Files / winsock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-13  |  28.1 KB  |  844 lines

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