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

Last change on this file since 46 was 46, checked in by sandervl, 26 years ago

* empty log message *

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