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.

916 lines
30 KiB

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