Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

915 lines
30 KiB

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