source: trunk/src/wsock32/wsock32.h@ 92

Last change on this file since 92 was 92, checked in by phaller, 26 years ago

Add: added cvs variable $Id$ to source files.

File size: 28.9 KB
Line 
1/* $Id: wsock32.h,v 1.3 1999-06-10 16:11:08 phaller Exp $ */
2
3/* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
4 * Unused/unneeded Microsoft declarations removed.
5 *
6 * This header file corresponds to version 1.1 of the Windows Sockets specification.
7 *
8 * This file includes parts which are Copyright (c) 1982-1986 Regents
9 * of the University of California. All rights reserved. The
10 * Berkeley Software License Agreement specifies the terms and
11 * conditions for redistribution.
12 *
13 */
14
15#ifndef _WINSOCKAPI_
16#define _WINSOCKAPI_
17
18#define FAR
19
20#ifndef IN
21#define IN
22#endif
23
24
25#ifdef MAKELONG
26#undef MAKELONG
27#endif
28#ifdef MAKEWORD
29#undef MAKEWORD
30#endif
31
32#ifdef LOBYTE
33#undef LOBYTE
34#endif
35#ifdef LOWORD
36#undef LOWORD
37#endif
38#ifdef HIBYTE
39#undef HIBYTE
40#endif
41#ifdef HIWORD
42#undef HIWORD
43#endif
44
45#define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))
46#define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
47#define LOWORD(l) ((WORD)(l))
48#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
49#define LOBYTE(w) ((BYTE)(w))
50#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
51
52
53
54/*
55 * Basic system type definitions, taken from the BSD file sys/types.h.
56 */
57
58#ifdef __WATCOM__
59typedef unsigned char u_char;
60typedef unsigned short u_short;
61typedef unsigned int u_int;
62typedef unsigned long u_long;
63//typedef int (FAR WINAPI *FARPROC)();
64#else
65//typedef int (* FAR WINAPI FARPROC)();
66#endif
67
68//typedef unsigned short WORD;
69//typedef unsigned long DWORD;
70//typedef ULONG HANDLE, *PHANDLE, *LPHANDLE, *SPHANDLE;
71
72/*
73 * The new type to be used in all
74 * instances which refer to sockets.
75 */
76typedef u_int SOCKET;
77
78
79
80
81typedef struct AsyncStatus {
82 HWND hwnd; // owner's hwindow
83 u_int msg; // message to send when event occurs
84 ULONG event; // event that may occur
85 SOCKET socket; // the socket
86 int status; // blocking yes/no
87 TID threadID; // Thread ID for async
88 int MsgStat; // has message been sent yet?
89 struct AsyncStatus *Next; // pointer to next AsyncStatus in the list
90 struct AsyncStatus *Prev; // pointer to previous AsyncStatus in the list
91} AsyncStatus;
92
93
94
95
96
97
98/*
99 * Select uses arrays of SOCKETs. These macros manipulate such
100 * arrays. FD_SETSIZE may be defined by the user before including
101 * this file, but the default here should be >= 64.
102 *
103 * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
104 * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
105 */
106#ifndef FD_SETSIZE
107#define FD_SETSIZE 64
108#endif /* FD_SETSIZE */
109
110typedef struct Wfd_set {
111 u_int fd_count; /* how many are SET? */
112 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
113} Wfd_set;
114
115#ifdef __cplusplus
116extern "C" {
117#endif
118
119extern int PASCAL FAR __WSAFDIsSet(SOCKET, Wfd_set FAR *);
120
121#ifdef __cplusplus
122}
123#endif
124
125
126#define FD_CLR(fd, set) do { \
127 u_int __i; \
128 for (__i = 0; __i < ((Wfd_set FAR *)(set))->fd_count ; __i++) { \
129 if (((Wfd_set FAR *)(set))->fd_array[__i] == fd) { \
130 while (__i < ((Wfd_set FAR *)(set))->fd_count-1) { \
131 ((Wfd_set FAR *)(set))->fd_array[__i] = \
132 ((Wfd_set FAR *)(set))->fd_array[__i+1]; \
133 __i++; \
134 } \
135 ((Wfd_set FAR *)(set))->fd_count--; \
136 break; \
137 } \
138 } \
139} while(0)
140
141#define FD_SET(fd, set) do { \
142 if (((Wfd_set FAR *)(set))->fd_count < FD_SETSIZE) \
143 ((Wfd_set FAR *)(set))->fd_array[((Wfd_set FAR *)(set))->fd_count++]=(fd);\
144} while(0)
145
146#define FD_ZERO(set) (((Wfd_set FAR *)(set))->fd_count=0)
147
148#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (Wfd_set FAR *)(set))
149
150/*
151 * Structure used in select() call, taken from the BSD file sys/time.h.
152 */
153struct Wtimeval {
154 long tv_sec; /* seconds */
155 long tv_usec; /* and microseconds */
156};
157
158/*
159 * Operations on timevals.
160 *
161 * NB: timercmp does not work for >= or <=.
162 */
163#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
164#define Wtimercmp(tvp, uvp, cmp) \
165 ((tvp)->tv_sec cmp (uvp)->tv_sec || \
166 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
167#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
168
169/*
170 * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
171 *
172 *
173 * Ioctl's have the command encoded in the lower word,
174 * and the size of any in or out parameters in the upper
175 * word. The high 2 bits of the upper word are used
176 * to encode the in/out status of the parameter; for now
177 * we restrict parameters to at most 128 bytes.
178 */
179#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
180#define IOC_VOID 0x20000000 /* no parameters */
181#define IOC_OUT 0x40000000 /* copy out parameters */
182#define IOC_IN 0x80000000 /* copy in parameters */
183#define IOC_INOUT (IOC_IN|IOC_OUT)
184 /* 0x20000000 distinguishes new &
185 old ioctl's */
186#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
187
188#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
189
190#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
191
192#define WFIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
193#define WFIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
194#define WFIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
195
196/* Socket I/O Controls */
197#define WSIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
198#define WSIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
199#define WSIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
200#define WSIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
201#define WSIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
202
203/*
204 * Structures returned by network data base library, taken from the
205 * BSD file netdb.h. All addresses are supplied in host order, and
206 * returned in network order (suitable for use in system calls).
207 */
208
209struct Whostent {
210 char FAR * h_name; /* official name of host */
211 char FAR * FAR * h_aliases; /* alias list */
212 short h_addrtype; /* host address type */
213 short h_length; /* length of address */
214 char FAR * FAR * h_addr_list; /* list of addresses */
215#define h_addr h_addr_list[0] /* address, for backward compat */
216};
217
218/*
219 * It is assumed here that a network number
220 * fits in 32 bits.
221 */
222struct Wnetent {
223 char FAR * n_name; /* official name of net */
224 char FAR * FAR * n_aliases; /* alias list */
225 short n_addrtype; /* net address type */
226 u_long n_net; /* network # */
227};
228
229struct Wservent {
230 char FAR * s_name; /* official service name */
231 char FAR * FAR * s_aliases; /* alias list */
232 short s_port; /* port # */
233 char FAR * s_proto; /* protocol to use */
234};
235
236struct Wprotoent {
237 char FAR * p_name; /* official protocol name */
238 char FAR * FAR * p_aliases; /* alias list */
239 short p_proto; /* protocol # */
240};
241
242/*
243 * Constants and structures defined by the internet system,
244 * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
245 */
246
247/*
248 * Protocols
249 */
250#define IPPROTO_IP 0 /* dummy for IP */
251#define IPPROTO_ICMP 1 /* control message protocol */
252//#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */
253#define IPPROTO_TCP 6 /* tcp */
254#define IPPROTO_PUP 12 /* pup */
255#define IPPROTO_UDP 17 /* user datagram protocol */
256#define IPPROTO_IDP 22 /* xns idp */
257#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
258
259#define IPPROTO_RAW 255 /* raw IP packet */
260#define IPPROTO_MAX 256
261
262/*
263 * Port/socket numbers: network standard functions
264 */
265#define IPPORT_ECHO 7
266#define IPPORT_DISCARD 9
267#define IPPORT_SYSTAT 11
268#define IPPORT_DAYTIME 13
269#define IPPORT_NETSTAT 15
270#define IPPORT_FTP 21
271#define IPPORT_TELNET 23
272#define IPPORT_SMTP 25
273#define IPPORT_TIMESERVER 37
274#define IPPORT_NAMESERVER 42
275#define IPPORT_WHOIS 43
276#define IPPORT_MTP 57
277
278/*
279 * Port/socket numbers: host specific functions
280 */
281#define IPPORT_TFTP 69
282#define IPPORT_RJE 77
283#define IPPORT_FINGER 79
284#define IPPORT_TTYLINK 87
285#define IPPORT_SUPDUP 95
286
287/*
288 * UNIX TCP sockets
289 */
290#define IPPORT_EXECSERVER 512
291#define IPPORT_LOGINSERVER 513
292#define IPPORT_CMDSERVER 514
293#define IPPORT_EFSSERVER 520
294
295/*
296 * UNIX UDP sockets
297 */
298#define IPPORT_BIFFUDP 512
299#define IPPORT_WHOSERVER 513
300#define IPPORT_ROUTESERVER 520
301 /* 520+1 also used */
302
303/*
304 * Ports < IPPORT_RESERVED are reserved for
305 * privileged processes (e.g. root).
306 */
307#define IPPORT_RESERVED 1024
308
309/*
310 * Link numbers
311 */
312#define IMPLINK_IP 155
313#define IMPLINK_LOWEXPER 156
314#define IMPLINK_HIGHEXPER 158
315
316/*
317 * Internet address (old style... should be updated)
318 */
319struct Win_addr {
320 union {
321 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
322 struct { u_short s_w1,s_w2; } S_un_w;
323 u_long S_addr;
324 } S_un;
325#define s_addr S_un.S_addr
326 /* can be used for most tcp & ip code */
327#define s_host S_un.S_un_b.s_b2
328 /* host on imp */
329#define s_net S_un.S_un_b.s_b1
330 /* network */
331#define s_imp S_un.S_un_w.s_w2
332 /* imp */
333#define s_impno S_un.S_un_b.s_b4
334 /* imp # */
335#define s_lh S_un.S_un_b.s_b3
336 /* logical host */
337};
338
339/*
340 * Definitions of bits in internet address integers.
341 * On subnets, the decomposition of addresses to host and net parts
342 * is done according to subnet mask, not the masks here.
343 */
344#define WIN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
345#define WIN_CLASSA_NET 0xff000000
346#define WIN_CLASSA_NSHIFT 24
347#define WIN_CLASSA_HOST 0x00ffffff
348#define WIN_CLASSA_MAX 128
349
350#define WIN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
351#define WIN_CLASSB_NET 0xffff0000
352#define WIN_CLASSB_NSHIFT 16
353#define WIN_CLASSB_HOST 0x0000ffff
354#define WIN_CLASSB_MAX 65536
355
356#define WIN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
357#define WIN_CLASSC_NET 0xffffff00
358#define WIN_CLASSC_NSHIFT 8
359#define WIN_CLASSC_HOST 0x000000ff
360
361#define WINADDR_ANY (u_long)0x00000000
362#define WINADDR_LOOPBACK 0x7f000001
363#define WINADDR_BROADCAST (u_long)0xffffffff
364#define WINADDR_NONE 0xffffffff
365
366/*
367 * Socket address, internet style.
368 */
369struct Wsockaddr_in {
370 short sin_family;
371 u_short sin_port;
372 struct in_addr sin_addr;
373 char sin_zero[8];
374};
375
376#define WSADESCRIPTION_LEN 256
377#define WSASYS_STATUS_LEN 128
378
379typedef struct WSAData {
380 WORD wVersion;
381 WORD wHighVersion;
382 char szDescription[WSADESCRIPTION_LEN+1];
383 char szSystemStatus[WSASYS_STATUS_LEN+1];
384 unsigned short iMaxSockets;
385 unsigned short iMaxUdpDg;
386 char FAR * lpVendorInfo;
387} WSADATA;
388
389typedef WSADATA FAR *LPWSADATA;
390
391/*
392 * Options for use with [gs]etsockopt at the IP level.
393 */
394#define IP_OPTIONS 1 /* set/get IP per-packet options */
395
396/*
397 * Definitions related to sockets: types, address families, options,
398 * taken from the BSD file sys/socket.h.
399 */
400
401/*
402 * This is used instead of -1, since the
403 * SOCKET type is unsigned.
404 */
405#define INVALID_SOCKET (SOCKET)(~0)
406#define SOCKET_ERROR (-1)
407
408/*
409 * Types
410 */
411#define SOCK_STREAM 1 /* stream socket */
412#define SOCK_DGRAM 2 /* datagram socket */
413#define SOCK_RAW 3 /* raw-protocol interface */
414#define SOCK_RDM 4 /* reliably-delivered message */
415#define SOCK_SEQPACKET 5 /* sequenced packet stream */
416
417/*
418 * Option flags per-socket.
419 */
420#define SO_DEBUG 0x0001 /* turn on debugging info recording */
421#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
422#define SO_REUSEADDR 0x0004 /* allow local address reuse */
423#define SO_KEEPALIVE 0x0008 /* keep connections alive */
424#define SO_DONTROUTE 0x0010 /* just use interface addresses */
425#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
426#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
427#define SO_LINGER 0x0080 /* linger on close if data present */
428#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
429
430#define SO_DONTLINGER (u_int)(~SO_LINGER)
431
432/*
433 * Additional options.
434 */
435#define SO_SNDBUF 0x1001 /* send buffer size */
436#define SO_RCVBUF 0x1002 /* receive buffer size */
437#define SO_SNDLOWAT 0x1003 /* send low-water mark */
438#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
439#define SO_SNDTIMEO 0x1005 /* send timeout */
440#define SO_RCVTIMEO 0x1006 /* receive timeout */
441#define SO_ERROR 0x1007 /* get error status and clear */
442#define SO_TYPE 0x1008 /* get socket type */
443
444
445/*
446 * TCP options.
447 */
448#define TCP_NODELAY 0x0001
449#define TCP_BSDURGENT 0x7000
450
451/*
452 * Address families.
453 */
454#define AF_UNSPEC 0 /* unspecified */
455#define AF_UNIX 1 /* local to host (pipes, portals) */
456#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
457#define AF_IMPLINK 3 /* arpanet imp addresses */
458#define AF_PUP 4 /* pup protocols: e.g. BSP */
459#define AF_CHAOS 5 /* mit CHAOS protocols */
460#define AF_IPX 6 /* IPX and SPX */
461#define AF_NS 6 /* XEROX NS protocols */
462#define AF_ISO 7 /* ISO protocols */
463#define AF_OSI AF_ISO /* OSI is ISO */
464#define AF_ECMA 8 /* european computer manufacturers */
465#define AF_DATAKIT 9 /* datakit protocols */
466#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
467#define AF_SNA 11 /* IBM SNA */
468#define AF_DECnet 12 /* DECnet */
469#define AF_DLI 13 /* Direct data link interface */
470#define AF_LAT 14 /* LAT */
471#define AF_HYLINK 15 /* NSC Hyperchannel */
472#define AF_APPLETALK 16 /* AppleTalk */
473//#define AF_NETBIOS 17 /* NetBios-style addresses */
474#define AF_VOICEVIEW 18 /* VoiceView */
475
476//#define AF_MAX 19
477
478/*
479 * Structure used by kernel to store most
480 * addresses.
481 */
482struct Wsockaddr {
483 u_short sa_family; /* address family */
484 char sa_data[14]; /* up to 14 bytes of direct address */
485};
486
487/*
488 * Structure used by kernel to pass protocol
489 * information in raw sockets.
490 */
491struct Wsockproto {
492 u_short sp_family; /* address family */
493 u_short sp_protocol; /* protocol */
494};
495
496/*
497 * Protocol families, same as address families for now.
498 */
499#define PF_UNSPEC AF_UNSPEC
500#define PF_UNIX AF_UNIX
501#define PF_INET AF_INET
502#define PF_IMPLINK AF_IMPLINK
503#define PF_PUP AF_PUP
504#define PF_CHAOS AF_CHAOS
505#define PF_NS AF_NS
506#define PF_IPX AF_IPX
507#define PF_ISO AF_ISO
508#define PF_OSI AF_OSI
509#define PF_ECMA AF_ECMA
510#define PF_DATAKIT AF_DATAKIT
511#define PF_CCITT AF_CCITT
512#define PF_SNA AF_SNA
513#define PF_DECnet AF_DECnet
514#define PF_DLI AF_DLI
515#define PF_LAT AF_LAT
516#define PF_HYLINK AF_HYLINK
517#define PF_APPLETALK AF_APPLETALK
518#define PF_VOICEVIEW AF_VOICEVIEW
519
520#define PF_MAX AF_MAX
521
522/*
523 * Structure used for manipulating linger option.
524 */
525struct Wlinger {
526 u_short l_onoff; /* option on/off */
527 u_short l_linger; /* linger time */
528};
529
530/*
531 * Level number for (get/set)sockopt() to apply to socket itself.
532 */
533#define SOL_SOCKET 0xffff /* options for socket level */
534
535/*
536 * Maximum queue length specifiable by listen.
537 */
538#define SOMAXCONN 5
539
540#define MSG_OOB 0x1 /* process out-of-band data */
541#define MSG_PEEK 0x2 /* peek at incoming message */
542#define MSG_DONTROUTE 0x4 /* send without using routing tables */
543
544#define MSG_MAXIOVLEN 16
545
546#define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
547
548/*
549 * Define constant based on rfc883, used by gethostbyxxxx() calls.
550 */
551#define MAXGETHOSTSTRUCT 1024
552
553/*
554 * Define flags to be used with the WSAAsyncSelect() call.
555 */
556#define FD_READ 0x01
557#define FD_WRITE 0x02
558#define FD_OOB 0x04
559#define FD_ACCEPT 0x08
560#define FD_CONNECT 0x10
561#define FD_CLOSE 0x20
562
563/*
564 * All Windows Sockets error constants are biased by WSABASEERR from
565 * the "normal"
566 */
567#define WSABASEERR 10000
568/*
569 * Windows Sockets definitions of regular Microsoft C error constants
570 */
571#define WSAEINTR (WSABASEERR+4)
572#define WSAEBADF (WSABASEERR+9)
573#define WSAEACCES (WSABASEERR+13)
574#define WSAEFAULT (WSABASEERR+14)
575#define WSAEINVAL (WSABASEERR+22)
576#define WSAEMFILE (WSABASEERR+24)
577
578/*
579 * Windows Sockets definitions of regular Berkeley error constants
580 */
581#define WSAEWOULDBLOCK (WSABASEERR+35)
582#define WSAEINPROGRESS (WSABASEERR+36)
583#define WSAEALREADY (WSABASEERR+37)
584#define WSAENOTSOCK (WSABASEERR+38)
585#define WSAEDESTADDRREQ (WSABASEERR+39)
586#define WSAEMSGSIZE (WSABASEERR+40)
587#define WSAEPROTOTYPE (WSABASEERR+41)
588#define WSAENOPROTOOPT (WSABASEERR+42)
589#define WSAEPROTONOSUPPORT (WSABASEERR+43)
590#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
591#define WSAEOPNOTSUPP (WSABASEERR+45)
592#define WSAEPFNOSUPPORT (WSABASEERR+46)
593#define WSAEAFNOSUPPORT (WSABASEERR+47)
594#define WSAEADDRINUSE (WSABASEERR+48)
595#define WSAEADDRNOTAVAIL (WSABASEERR+49)
596#define WSAENETDOWN (WSABASEERR+50)
597#define WSAENETUNREACH (WSABASEERR+51)
598#define WSAENETRESET (WSABASEERR+52)
599#define WSAECONNABORTED (WSABASEERR+53)
600#define WSAECONNRESET (WSABASEERR+54)
601#define WSAENOBUFS (WSABASEERR+55)
602#define WSAEISCONN (WSABASEERR+56)
603#define WSAENOTCONN (WSABASEERR+57)
604#define WSAESHUTDOWN (WSABASEERR+58)
605#define WSAETOOMANYREFS (WSABASEERR+59)
606#define WSAETIMEDOUT (WSABASEERR+60)
607#define WSAECONNREFUSED (WSABASEERR+61)
608#define WSAELOOP (WSABASEERR+62)
609#define WSAENAMETOOLONG (WSABASEERR+63)
610#define WSAEHOSTDOWN (WSABASEERR+64)
611#define WSAEHOSTUNREACH (WSABASEERR+65)
612#define WSAENOTEMPTY (WSABASEERR+66)
613#define WSAEPROCLIM (WSABASEERR+67)
614#define WSAEUSERS (WSABASEERR+68)
615#define WSAEDQUOT (WSABASEERR+69)
616#define WSAESTALE (WSABASEERR+70)
617#define WSAEREMOTE (WSABASEERR+71)
618
619#define WSAEDISCON (WSABASEERR+101)
620
621/*
622 * Extended Windows Sockets error constant definitions
623 */
624#define WSASYSNOTREADY (WSABASEERR+91)
625#define WSAVERNOTSUPPORTED (WSABASEERR+92)
626#define WSANOTINITIALISED (WSABASEERR+93)
627
628/*
629 * Error return codes from gethostbyname() and gethostbyaddr()
630 * (when using the resolver). Note that these errors are
631 * retrieved via WSAGetLastError() and must therefore follow
632 * the rules for avoiding clashes with error numbers from
633 * specific implementations or language run-time systems.
634 * For this reason the codes are based at WSABASEERR+1001.
635 * Note also that [WSA]NO_ADDRESS is defined only for
636 * compatibility purposes.
637 */
638
639#define Wh_errno WSAGetLastError()
640
641/* Authoritative Answer: Host not found */
642#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
643#define WHOST_NOT_FOUND WSAHOST_NOT_FOUND
644
645/* Non-Authoritative: Host not found, or SERVERFAIL */
646#define WSATRY_AGAIN (WSABASEERR+1002)
647#define WTRY_AGAIN WSATRY_AGAIN
648
649/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
650#define WSANO_RECOVERY (WSABASEERR+1003)
651#define WNO_RECOVERY WSANO_RECOVERY
652
653/* Valid name, no data record of requested type */
654#define WSANO_DATA (WSABASEERR+1004)
655#define WNO_DATA WSANO_DATA
656
657/* no address, look for MX record */
658#define WSANO_ADDRESS WSANO_DATA
659#define WNO_ADDRESS WSANO_ADDRESS
660
661
662/* Socket function prototypes */
663
664#ifdef __cplusplus
665extern "C" {
666#endif
667
668SOCKET WIN32API FAR OS2accept (SOCKET s, struct sockaddr *addr,
669 int *addrlen);
670
671int WIN32API FAR OS2bind (SOCKET s, const struct sockaddr FAR *addr, int namelen);
672
673int WIN32API FAR OS2closesocket (SOCKET s);
674
675int WIN32API FAR OS2connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
676
677int WIN32API FAR OS2ioctlsocket (SOCKET s, long cmd, u_long FAR *argp);
678
679int WIN32API FAR OS2getpeername (SOCKET s, struct sockaddr FAR *name,
680 int FAR * namelen);
681
682int WIN32API FAR OS2getsockname (SOCKET s, struct sockaddr FAR *name,
683 int FAR * namelen);
684
685int WIN32API FAR OS2getsockopt (SOCKET s, int level, int optname,
686 char FAR * optval, int FAR *optlen);
687
688u_long WIN32API FAR OS2htonl (u_long hostlong);
689
690u_short WIN32API FAR OS2htons (u_short hostshort);
691
692unsigned long WIN32API FAR OS2inet_addr (const char FAR * cp);
693
694char FAR * WIN32API FAR OS2inet_ntoa (struct in_addr in);
695
696int WIN32API FAR OS2listen (SOCKET s, int backlog);
697
698u_long WIN32API FAR OS2ntohl (u_long netlong);
699
700u_short WIN32API FAR OS2ntohs (u_short netshort);
701
702int WIN32API FAR OS2recv (SOCKET s, char FAR * buf, int len, int flags);
703
704int WIN32API FAR OS2recvfrom (SOCKET s, char FAR * buf, int len, int flags,
705 struct sockaddr FAR *from, int FAR * fromlen);
706
707int WIN32API FAR OS2select (int nfds, Wfd_set FAR *readfds, Wfd_set FAR *writefds,
708 Wfd_set FAR *exceptfds, const struct Wtimeval FAR *timeout);
709
710int WIN32API FAR OS2send (SOCKET s, const char FAR * buf, int len, int flags);
711
712int WIN32API FAR OS2sendto (SOCKET s, const char FAR * buf, int len, int flags,
713 const struct sockaddr FAR *to, int tolen);
714
715int WIN32API FAR OS2setsockopt (SOCKET s, int level, int optname,
716 const char FAR * optval, int optlen);
717
718int WIN32API FAR OS2shutdown (SOCKET s, int how);
719
720SOCKET WIN32API FAR OS2socket (int af, int type, int protocol);
721
722/* Database function prototypes */
723
724struct Whostent FAR * WIN32API FAR OS2gethostbyaddr(const char FAR * addr,
725 int len, int type);
726
727struct Whostent FAR * WIN32API FAR OS2gethostbyname(const char FAR * name);
728
729int WIN32API FAR OS2gethostname (char FAR * name, int namelen);
730
731struct Wservent FAR * WIN32API FAR OS2getservbyport(int port, const char FAR * proto);
732
733struct Wservent FAR * WIN32API FAR OS2getservbyname(const char FAR * name,
734 const char FAR * proto);
735
736struct Wprotoent FAR * WIN32API FAR OS2getprotobynumber(int proto);
737
738struct Wprotoent FAR * WIN32API FAR OS2getprotobyname(const char FAR * name);
739
740/* Microsoft Windows Extension function prototypes */
741
742int WIN32API FAR OS2WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
743
744int WIN32API FAR OS2WSACleanup(void);
745
746void WIN32API FAR OS2WSASetLastError(int iError);
747
748int WIN32API FAR OS2WSAGetLastError(void);
749
750BOOL WIN32API FAR OS2WSAIsBlocking(void);
751
752int WIN32API FAR OS2WSAUnhookBlockingHook(void);
753
754FARPROC WIN32API FAR OS2WSASetBlockingHook(FARPROC lpBlockFunc);
755
756int WIN32API FAR OS2WSACancelBlockingCall(void);
757
758HANDLE WIN32API FAR OS2WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
759 const char FAR * name,
760 const char FAR * proto,
761 char FAR * buf, int buflen);
762
763HANDLE WIN32API FAR OS2WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
764 const char FAR * proto, char FAR * buf,
765 int buflen);
766
767HANDLE WIN32API FAR OS2WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
768 const char FAR * name, char FAR * buf,
769 int buflen);
770
771HANDLE WIN32API FAR OS2WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
772 int number, char FAR * buf,
773 int buflen);
774
775HANDLE WIN32API FAR OS2WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
776 const char FAR * name, char FAR * buf,
777 int buflen);
778
779HANDLE WIN32API FAR OS2WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
780 const char FAR * addr, int len, int type,
781 char FAR * buf, int buflen);
782
783int WIN32API FAR OS2WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
784
785int WIN32API FAR OS2WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
786 long lEvent);
787
788int WIN32API FAR OS2WSARecvEx (SOCKET s, char FAR * buf, int len, int FAR *flags);
789
790typedef struct _TRANSMIT_FILE_BUFFERS {
791 PVOID Head;
792 DWORD HeadLength;
793 PVOID Tail;
794 DWORD TailLength;
795} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
796
797typedef struct _OVERLAPPED {
798 DWORD Internal;
799 DWORD InternalHigh;
800 DWORD Offset;
801 DWORD OffsetHigh;
802 HANDLE hEvent;
803} OVERLAPPED, *LPOVERLAPPED;
804
805
806
807BOOL
808WIN32API FAR
809OS2TransmitFile (
810 IN SOCKET hSocket,
811 IN HANDLE hFile,
812 IN DWORD nNumberOfBytesToWrite,
813 IN DWORD nNumberOfBytesPerSend,
814 IN LPOVERLAPPED lpOverlapped,
815 IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
816 IN DWORD dwReserved
817 );
818
819#ifdef __cplusplus
820}
821#endif
822
823typedef struct sockaddr SOCKADDR;
824typedef struct sockaddr *PSOCKADDR;
825typedef struct sockaddr FAR *LPSOCKADDR;
826
827typedef struct sockaddr_in SOCKADDR_IN;
828typedef struct sockaddr_in *PSOCKADDR_IN;
829typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
830
831typedef struct linger LINGER;
832typedef struct linger *PLINGER;
833typedef struct linger FAR *LPLINGER;
834
835typedef struct in_addr IN_ADDR;
836typedef struct in_addr *PIN_ADDR;
837typedef struct in_addr FAR *LPIN_ADDR;
838
839typedef struct Wfd_set WFD_SET;
840typedef struct Wfd_set *PWFD_SET;
841typedef struct Wfd_set FAR *LPWFD_SET;
842
843typedef struct Whostent WHOSTENT;
844typedef struct Whostent *PWHOSTENT;
845typedef struct Whostent FAR *LPWHOSTENT;
846
847typedef struct Wservent WSERVENT;
848typedef struct Wservent *PWSERVENT;
849typedef struct Wservent FAR *LPWSERVENT;
850
851typedef struct Wprotoent WPROTOENT;
852typedef struct Wprotoent *PWPROTOENT;
853typedef struct Wprotoent FAR *LPWPROTOENT;
854
855typedef struct Wtimeval WTIMEVAL;
856typedef struct Wtimeval *PWTIMEVAL;
857typedef struct Wtimeval FAR *LPWTIMEVAL;
858
859/*
860 * Windows message parameter composition and decomposition
861 * macros.
862 *
863 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
864 * when constructing the response to a WSAAsyncGetXByY() routine.
865 */
866#define OS2WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
867/*
868 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
869 * when constructing the response to WSAAsyncSelect().
870 */
871#define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
872/*
873 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
874 * to extract the buffer length from the lParam in the response
875 * to a WSAGetXByY().
876 */
877#define OS2WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
878/*
879 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
880 * to extract the error code from the lParam in the response
881 * to a WSAGetXByY().
882 */
883#define OS2WSAGETASYNCERROR(lParam) HIWORD(lParam)
884/*
885 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
886 * to extract the event code from the lParam in the response
887 * to a WSAAsyncSelect().
888 */
889#define OS2WSAGETSELECTEVENT(lParam) LOWORD(lParam)
890/*
891 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
892 * to extract the error code from the lParam in the response
893 * to a WSAAsyncSelect().
894 */
895#define OS2WSAGETSELECTERROR(lParam) HIWORD(lParam)
896
897#endif /* _WINSOCKAPI_ */
898
899
Note: See TracBrowser for help on using the repository browser.