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

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

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