mpdosock.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. #define FAR
  15. #define PASCAL
  16. /*
  17. * Basic system type definitions, taken from the BSD file sys/types.h.
  18. */
  19. typedef unsigned char u_char;
  20. typedef unsigned short u_short;
  21. typedef unsigned int u_int;
  22. typedef unsigned long u_long;
  23. /*
  24. * The new type to be used in all
  25. * instances which refer to sockets.
  26. */
  27. typedef u_int SOCKET;
  28. // FIXME
  29. #if 0
  30. /*
  31. * Select uses arrays of SOCKETs. These macros manipulate such
  32. * arrays. FD_SETSIZE may be defined by the user before including
  33. * this file, but the default here should be >= 64.
  34. *
  35. * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
  36. * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
  37. */
  38. #ifndef FD_SETSIZE
  39. #define FD_SETSIZE 64
  40. #endif /* FD_SETSIZE */
  41. typedef struct fd_set {
  42. u_int fd_count; /* how many are SET? */
  43. SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
  44. } fd_set;
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #define FD_CLR(fd, set) do { \
  53. u_int __i; \
  54. for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
  55. if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \
  56. while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
  57. ((fd_set FAR *)(set))->fd_array[__i] = \
  58. ((fd_set FAR *)(set))->fd_array[__i+1]; \
  59. __i++; \
  60. } \
  61. ((fd_set FAR *)(set))->fd_count--; \
  62. break; \
  63. } \
  64. } \
  65. } while(0)
  66. #define FD_SET(fd, set) do { \
  67. if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \
  68. ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=(fd);\
  69. } while(0)
  70. #define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)
  71. #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))
  72. /*
  73. * Structure used in select() call, taken from the BSD file sys/time.h.
  74. */
  75. struct timeval {
  76. long tv_sec; /* seconds */
  77. long tv_usec; /* and microseconds */
  78. };
  79. /*
  80. * Operations on timevals.
  81. *
  82. * NB: timercmp does not work for >= or <=.
  83. */
  84. #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  85. #define timercmp(tvp, uvp, cmp) \
  86. ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  87. (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  88. #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
  89. #endif
  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. /*
  275. * Options for use with [gs]etsockopt at the IP level.
  276. */
  277. #define IP_OPTIONS 1 /* set/get IP per-packet options */
  278. #define IP_MULTICAST_IF 2 /* set/get IP multicast interface */
  279. #define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */
  280. #define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */
  281. #define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */
  282. #define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */
  283. #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
  284. #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
  285. #define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
  286. /*
  287. * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
  288. */
  289. struct ip_mreq {
  290. struct in_addr imr_multiaddr; /* IP multicast address of group */
  291. struct in_addr imr_interface; /* local IP address of interface */
  292. };
  293. /*
  294. * Definitions related to sockets: types, address families, options,
  295. * taken from the BSD file sys/socket.h.
  296. */
  297. /*
  298. * This is used instead of -1, since the
  299. * SOCKET type is unsigned.
  300. */
  301. #define INVALID_SOCKET (SOCKET)(~0)
  302. #define SOCKET_ERROR (-1)
  303. /*
  304. * Types
  305. */
  306. #define SOCK_STREAM 1 /* stream socket */
  307. #define SOCK_DGRAM 2 /* datagram socket */
  308. #define SOCK_RAW 3 /* raw-protocol interface */
  309. #define SOCK_RDM 4 /* reliably-delivered message */
  310. #define SOCK_SEQPACKET 5 /* sequenced packet stream */
  311. /*
  312. * Option flags per-socket.
  313. */
  314. #define SO_DEBUG 0x0001 /* turn on debugging info recording */
  315. #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
  316. #define SO_REUSEADDR 0x0004 /* allow local address reuse */
  317. #define SO_KEEPALIVE 0x0008 /* keep connections alive */
  318. #define SO_DONTROUTE 0x0010 /* just use interface addresses */
  319. #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
  320. #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
  321. #define SO_LINGER 0x0080 /* linger on close if data present */
  322. #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
  323. #define SO_DONTLINGER (u_int)(~SO_LINGER)
  324. /*
  325. * Additional options.
  326. */
  327. #define SO_SNDBUF 0x1001 /* send buffer size */
  328. #define SO_RCVBUF 0x1002 /* receive buffer size */
  329. #define SO_SNDLOWAT 0x1003 /* send low-water mark */
  330. #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
  331. #define SO_SNDTIMEO 0x1005 /* send timeout */
  332. #define SO_RCVTIMEO 0x1006 /* receive timeout */
  333. #define SO_ERROR 0x1007 /* get error status and clear */
  334. #define SO_TYPE 0x1008 /* get socket type */
  335. /*
  336. * Options for connect and disconnect data and options. Used only by
  337. * non-TCP/IP transports such as DECNet, OSI TP4, etc.
  338. */
  339. #define SO_CONNDATA 0x7000
  340. #define SO_CONNOPT 0x7001
  341. #define SO_DISCDATA 0x7002
  342. #define SO_DISCOPT 0x7003
  343. #define SO_CONNDATALEN 0x7004
  344. #define SO_CONNOPTLEN 0x7005
  345. #define SO_DISCDATALEN 0x7006
  346. #define SO_DISCOPTLEN 0x7007
  347. /*
  348. * Option for opening sockets for synchronous access.
  349. */
  350. #define SO_OPENTYPE 0x7008
  351. #define SO_SYNCHRONOUS_ALERT 0x10
  352. #define SO_SYNCHRONOUS_NONALERT 0x20
  353. /*
  354. * Other NT-specific options.
  355. */
  356. #define SO_MAXDG 0x7009
  357. #define SO_MAXPATHDG 0x700A
  358. /*
  359. * TCP options.
  360. */
  361. #define TCP_NODELAY 0x0001
  362. #define TCP_BSDURGENT 0x7000
  363. /*
  364. * Address families.
  365. */
  366. #define AF_UNSPEC 0 /* unspecified */
  367. #define AF_UNIX 1 /* local to host (pipes, portals) */
  368. #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
  369. #define AF_IMPLINK 3 /* arpanet imp addresses */
  370. #define AF_PUP 4 /* pup protocols: e.g. BSP */
  371. #define AF_CHAOS 5 /* mit CHAOS protocols */
  372. #define AF_IPX 6 /* IPX and SPX */
  373. #define AF_NS 6 /* XEROX NS protocols */
  374. #define AF_ISO 7 /* ISO protocols */
  375. #define AF_OSI AF_ISO /* OSI is ISO */
  376. #define AF_ECMA 8 /* european computer manufacturers */
  377. #define AF_DATAKIT 9 /* datakit protocols */
  378. #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
  379. #define AF_SNA 11 /* IBM SNA */
  380. #define AF_DECnet 12 /* DECnet */
  381. #define AF_DLI 13 /* Direct data link interface */
  382. #define AF_LAT 14 /* LAT */
  383. #define AF_HYLINK 15 /* NSC Hyperchannel */
  384. #define AF_APPLETALK 16 /* AppleTalk */
  385. #define AF_NETBIOS 17 /* NetBios-style addresses */
  386. #define AF_VOICEVIEW 18 /* VoiceView */
  387. #define AF_MAX 19
  388. /*
  389. * Structure used by kernel to store most
  390. * addresses.
  391. */
  392. struct sockaddr {
  393. u_short sa_family; /* address family */
  394. char sa_data[14]; /* up to 14 bytes of direct address */
  395. };
  396. /*
  397. * Structure used by kernel to pass protocol
  398. * information in raw sockets.
  399. */
  400. struct sockproto {
  401. u_short sp_family; /* address family */
  402. u_short sp_protocol; /* protocol */
  403. };
  404. /*
  405. * Protocol families, same as address families for now.
  406. */
  407. #define PF_UNSPEC AF_UNSPEC
  408. #define PF_UNIX AF_UNIX
  409. #define PF_INET AF_INET
  410. #define PF_IMPLINK AF_IMPLINK
  411. #define PF_PUP AF_PUP
  412. #define PF_CHAOS AF_CHAOS
  413. #define PF_NS AF_NS
  414. #define PF_IPX AF_IPX
  415. #define PF_ISO AF_ISO
  416. #define PF_OSI AF_OSI
  417. #define PF_ECMA AF_ECMA
  418. #define PF_DATAKIT AF_DATAKIT
  419. #define PF_CCITT AF_CCITT
  420. #define PF_SNA AF_SNA
  421. #define PF_DECnet AF_DECnet
  422. #define PF_DLI AF_DLI
  423. #define PF_LAT AF_LAT
  424. #define PF_HYLINK AF_HYLINK
  425. #define PF_APPLETALK AF_APPLETALK
  426. #define PF_VOICEVIEW AF_VOICEVIEW
  427. #define PF_MAX AF_MAX
  428. /*
  429. * Structure used for manipulating linger option.
  430. */
  431. struct linger {
  432. u_short l_onoff; /* option on/off */
  433. u_short l_linger; /* linger time */
  434. };
  435. /*
  436. * Level number for (get/set)sockopt() to apply to socket itself.
  437. */
  438. #define SOL_SOCKET 0xffff /* options for socket level */
  439. /*
  440. * Maximum queue length specifiable by listen.
  441. */
  442. #define SOMAXCONN 5
  443. #define MSG_OOB 0x1 /* process out-of-band data */
  444. #define MSG_PEEK 0x2 /* peek at incoming message */
  445. #define MSG_DONTROUTE 0x4 /* send without using routing tables */
  446. #define MSG_MAXIOVLEN 16
  447. #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
  448. /*
  449. * Define constant based on rfc883, used by gethostbyxxxx() calls.
  450. */
  451. #define MAXGETHOSTSTRUCT 1024
  452. /*
  453. * Define flags to be used with the WSAAsyncSelect() call.
  454. */
  455. #define FD_READ 0x01
  456. #define FD_WRITE 0x02
  457. #define FD_OOB 0x04
  458. #define FD_ACCEPT 0x08
  459. #define FD_CONNECT 0x10
  460. #define FD_CLOSE 0x20
  461. /*
  462. * All Windows Sockets error constants are biased by WSABASEERR from
  463. * the "normal"
  464. */
  465. #define WSABASEERR 10000
  466. /*
  467. * Windows Sockets definitions of regular Microsoft C error constants
  468. */
  469. #define WSAEINTR (WSABASEERR+4)
  470. #define WSAEBADF (WSABASEERR+9)
  471. #define WSAEACCES (WSABASEERR+13)
  472. #define WSAEFAULT (WSABASEERR+14)
  473. #define WSAEINVAL (WSABASEERR+22)
  474. #define WSAEMFILE (WSABASEERR+24)
  475. /*
  476. * Windows Sockets definitions of regular Berkeley error constants
  477. */
  478. #define WSAEWOULDBLOCK (WSABASEERR+35)
  479. #define WSAEINPROGRESS (WSABASEERR+36)
  480. #define WSAEALREADY (WSABASEERR+37)
  481. #define WSAENOTSOCK (WSABASEERR+38)
  482. #define WSAEDESTADDRREQ (WSABASEERR+39)
  483. #define WSAEMSGSIZE (WSABASEERR+40)
  484. #define WSAEPROTOTYPE (WSABASEERR+41)
  485. #define WSAENOPROTOOPT (WSABASEERR+42)
  486. #define WSAEPROTONOSUPPORT (WSABASEERR+43)
  487. #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
  488. #define WSAEOPNOTSUPP (WSABASEERR+45)
  489. #define WSAEPFNOSUPPORT (WSABASEERR+46)
  490. #define WSAEAFNOSUPPORT (WSABASEERR+47)
  491. #define WSAEADDRINUSE (WSABASEERR+48)
  492. #define WSAEADDRNOTAVAIL (WSABASEERR+49)
  493. #define WSAENETDOWN (WSABASEERR+50)
  494. #define WSAENETUNREACH (WSABASEERR+51)
  495. #define WSAENETRESET (WSABASEERR+52)
  496. #define WSAECONNABORTED (WSABASEERR+53)
  497. #define WSAECONNRESET (WSABASEERR+54)
  498. #define WSAENOBUFS (WSABASEERR+55)
  499. #define WSAEISCONN (WSABASEERR+56)
  500. #define WSAENOTCONN (WSABASEERR+57)
  501. #define WSAESHUTDOWN (WSABASEERR+58)
  502. #define WSAETOOMANYREFS (WSABASEERR+59)
  503. #define WSAETIMEDOUT (WSABASEERR+60)
  504. #define WSAECONNREFUSED (WSABASEERR+61)
  505. #define WSAELOOP (WSABASEERR+62)
  506. #define WSAENAMETOOLONG (WSABASEERR+63)
  507. #define WSAEHOSTDOWN (WSABASEERR+64)
  508. #define WSAEHOSTUNREACH (WSABASEERR+65)
  509. #define WSAENOTEMPTY (WSABASEERR+66)
  510. #define WSAEPROCLIM (WSABASEERR+67)
  511. #define WSAEUSERS (WSABASEERR+68)
  512. #define WSAEDQUOT (WSABASEERR+69)
  513. #define WSAESTALE (WSABASEERR+70)
  514. #define WSAEREMOTE (WSABASEERR+71)
  515. #define WSAEDISCON (WSABASEERR+101)
  516. /*
  517. * Extended Windows Sockets error constant definitions
  518. */
  519. #define WSASYSNOTREADY (WSABASEERR+91)
  520. #define WSAVERNOTSUPPORTED (WSABASEERR+92)
  521. #define WSANOTINITIALISED (WSABASEERR+93)
  522. /*
  523. * Error return codes from gethostbyname() and gethostbyaddr()
  524. * (when using the resolver). Note that these errors are
  525. * retrieved via WSAGetLastError() and must therefore follow
  526. * the rules for avoiding clashes with error numbers from
  527. * specific implementations or language run-time systems.
  528. * For this reason the codes are based at WSABASEERR+1001.
  529. * Note also that [WSA]NO_ADDRESS is defined only for
  530. * compatibility purposes.
  531. */
  532. #define h_errno WSAGetLastError()
  533. /* Authoritative Answer: Host not found */
  534. #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
  535. #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
  536. /* Non-Authoritative: Host not found, or SERVERFAIL */
  537. #define WSATRY_AGAIN (WSABASEERR+1002)
  538. #define TRY_AGAIN WSATRY_AGAIN
  539. /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  540. #define WSANO_RECOVERY (WSABASEERR+1003)
  541. #define NO_RECOVERY WSANO_RECOVERY
  542. /* Valid name, no data record of requested type */
  543. #define WSANO_DATA (WSABASEERR+1004)
  544. #define NO_DATA WSANO_DATA
  545. /* no address, look for MX record */
  546. #define WSANO_ADDRESS WSANO_DATA
  547. #define NO_ADDRESS WSANO_ADDRESS
  548. /*
  549. * Windows Sockets errors redefined as regular Berkeley error constants.
  550. * These are commented out in Windows NT to avoid conflicts with errno.h.
  551. * Use the WSA constants instead.
  552. */
  553. #if 0
  554. #define EWOULDBLOCK WSAEWOULDBLOCK
  555. #define EINPROGRESS WSAEINPROGRESS
  556. #define EALREADY WSAEALREADY
  557. #define ENOTSOCK WSAENOTSOCK
  558. #define EDESTADDRREQ WSAEDESTADDRREQ
  559. #define EMSGSIZE WSAEMSGSIZE
  560. #define EPROTOTYPE WSAEPROTOTYPE
  561. #define ENOPROTOOPT WSAENOPROTOOPT
  562. #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
  563. #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
  564. #define EOPNOTSUPP WSAEOPNOTSUPP
  565. #define EPFNOSUPPORT WSAEPFNOSUPPORT
  566. #define EAFNOSUPPORT WSAEAFNOSUPPORT
  567. #define EADDRINUSE WSAEADDRINUSE
  568. #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
  569. #define ENETDOWN WSAENETDOWN
  570. #define ENETUNREACH WSAENETUNREACH
  571. #define ENETRESET WSAENETRESET
  572. #define ECONNABORTED WSAECONNABORTED
  573. #define ECONNRESET WSAECONNRESET
  574. #define ENOBUFS WSAENOBUFS
  575. #define EISCONN WSAEISCONN
  576. #define ENOTCONN WSAENOTCONN
  577. #define ESHUTDOWN WSAESHUTDOWN
  578. #define ETOOMANYREFS WSAETOOMANYREFS
  579. #define ETIMEDOUT WSAETIMEDOUT
  580. #define ECONNREFUSED WSAECONNREFUSED
  581. #define ELOOP WSAELOOP
  582. #define ENAMETOOLONG WSAENAMETOOLONG
  583. #define EHOSTDOWN WSAEHOSTDOWN
  584. #define EHOSTUNREACH WSAEHOSTUNREACH
  585. #define ENOTEMPTY WSAENOTEMPTY
  586. #define EPROCLIM WSAEPROCLIM
  587. #define EUSERS WSAEUSERS
  588. #define EDQUOT WSAEDQUOT
  589. #define ESTALE WSAESTALE
  590. #define EREMOTE WSAEREMOTE
  591. #endif
  592. /* Socket function prototypes */
  593. #ifdef __cplusplus
  594. extern "C" {
  595. #endif
  596. SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr,
  597. int FAR *addrlen);
  598. int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *addr, int namelen);
  599. int PASCAL FAR closesocket (SOCKET s);
  600. int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
  601. int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp);
  602. int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name,
  603. int FAR * namelen);
  604. int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name,
  605. int FAR * namelen);
  606. int PASCAL FAR getsockopt (SOCKET s, int level, int optname,
  607. char FAR * optval, int FAR *optlen);
  608. u_long PASCAL FAR htonl (u_long hostlong);
  609. u_short PASCAL FAR htons (u_short hostshort);
  610. unsigned long PASCAL FAR inet_addr (const char FAR * cp);
  611. char FAR * PASCAL FAR inet_ntoa (struct in_addr in);
  612. int PASCAL FAR listen (SOCKET s, int backlog);
  613. u_long PASCAL FAR ntohl (u_long netlong);
  614. u_short PASCAL FAR ntohs (u_short netshort);
  615. int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags);
  616. int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags,
  617. struct sockaddr FAR *from, int FAR * fromlen);
  618. #if 0
  619. int PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set FAR *writefds,
  620. fd_set FAR *exceptfds, const struct timeval FAR *timeout);
  621. #endif
  622. int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int flags);
  623. int PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, int flags,
  624. const struct sockaddr FAR *to, int tolen);
  625. int PASCAL FAR setsockopt (SOCKET s, int level, int optname,
  626. const char FAR * optval, int optlen);
  627. int PASCAL FAR shutdown (SOCKET s, int how);
  628. SOCKET PASCAL FAR socket (int af, int type, int protocol);
  629. /* Database function prototypes */
  630. struct hostent FAR * PASCAL FAR gethostbyaddr(const char FAR * addr,
  631. int len, int type);
  632. struct hostent FAR * PASCAL FAR gethostbyname(const char FAR * name);
  633. int PASCAL FAR gethostname (char FAR * name, int namelen);
  634. struct servent FAR * PASCAL FAR getservbyport(int port, const char FAR * proto);
  635. struct servent FAR * PASCAL FAR getservbyname(const char FAR * name,
  636. const char FAR * proto);
  637. struct protoent FAR * PASCAL FAR getprotobynumber(int proto);
  638. struct protoent FAR * PASCAL FAR getprotobyname(const char FAR * name);
  639. #ifdef __cplusplus
  640. }
  641. #endif
  642. /* Microsoft Windows Extended data types */
  643. typedef struct sockaddr SOCKADDR;
  644. typedef struct sockaddr *PSOCKADDR;
  645. typedef struct sockaddr FAR *LPSOCKADDR;
  646. typedef struct sockaddr_in SOCKADDR_IN;
  647. typedef struct sockaddr_in *PSOCKADDR_IN;
  648. typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
  649. typedef struct linger LINGER;
  650. typedef struct linger *PLINGER;
  651. typedef struct linger FAR *LPLINGER;
  652. typedef struct in_addr IN_ADDR;
  653. typedef struct in_addr *PIN_ADDR;
  654. typedef struct in_addr FAR *LPIN_ADDR;
  655. typedef struct fd_set FD_SET;
  656. typedef struct fd_set *PFD_SET;
  657. typedef struct fd_set FAR *LPFD_SET;
  658. typedef struct hostent HOSTENT;
  659. typedef struct hostent *PHOSTENT;
  660. typedef struct hostent FAR *LPHOSTENT;
  661. typedef struct servent SERVENT;
  662. typedef struct servent *PSERVENT;
  663. typedef struct servent FAR *LPSERVENT;
  664. typedef struct protoent PROTOENT;
  665. typedef struct protoent *PPROTOENT;
  666. typedef struct protoent FAR *LPPROTOENT;
  667. typedef struct timeval TIMEVAL;
  668. typedef struct timeval *PTIMEVAL;
  669. typedef struct timeval FAR *LPTIMEVAL;
  670. #endif /* _WINSOCKAPI_ */