1 | /* $Id: winsock.h,v 1.5 2001-07-03 14:46:00 achimha Exp $ */
|
---|
2 |
|
---|
3 | /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
|
---|
4 | *
|
---|
5 | * This header file corresponds to version 1.1 of the Windows Sockets
|
---|
6 | * specification.
|
---|
7 | */
|
---|
8 |
|
---|
9 | #ifndef _WINSOCKAPI_
|
---|
10 | #define _WINSOCKAPI_
|
---|
11 |
|
---|
12 | #ifndef __WINE_WINDOWS_H
|
---|
13 | #include <windows.h>
|
---|
14 | #endif // __WINE_WINDOWS_H
|
---|
15 |
|
---|
16 | typedef unsigned char u_char;
|
---|
17 | typedef unsigned short u_short;
|
---|
18 | typedef unsigned int u_int;
|
---|
19 | typedef unsigned long u_long;
|
---|
20 | typedef u_int SOCKET;
|
---|
21 |
|
---|
22 | #ifndef FD_SETSIZE
|
---|
23 | #define FD_SETSIZE 64
|
---|
24 | #endif /* FD_SETSIZE */
|
---|
25 |
|
---|
26 | typedef struct fd_set {
|
---|
27 | u_int fd_count;
|
---|
28 | SOCKET fd_array[FD_SETSIZE];
|
---|
29 | } fd_set;
|
---|
30 |
|
---|
31 | #ifdef __cplusplus
|
---|
32 | extern "C" {
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | extern int WIN32API __WSAFDIsSet(SOCKET, fd_set *);
|
---|
36 |
|
---|
37 | #ifdef __cplusplus
|
---|
38 | }
|
---|
39 | #endif
|
---|
40 |
|
---|
41 |
|
---|
42 | #define FD_CLR(fd, set) do { \
|
---|
43 | u_int __i; \
|
---|
44 | for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) { \
|
---|
45 | if (((fd_set *)(set))->fd_array[__i] == fd) { \
|
---|
46 | while (__i < ((fd_set *)(set))->fd_count-1) { \
|
---|
47 | ((fd_set *)(set))->fd_array[__i] = \
|
---|
48 | ((fd_set *)(set))->fd_array[__i+1]; \
|
---|
49 | __i++; \
|
---|
50 | } \
|
---|
51 | ((fd_set *)(set))->fd_count--; \
|
---|
52 | break; \
|
---|
53 | } \
|
---|
54 | } \
|
---|
55 | } while(0)
|
---|
56 |
|
---|
57 | #define FD_SET(fd, set) do { \
|
---|
58 | if (((fd_set *)(set))->fd_count < FD_SETSIZE) \
|
---|
59 | ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=(fd);\
|
---|
60 | } while(0)
|
---|
61 |
|
---|
62 | #define FD_ZERO(set) (((fd_set *)(set))->fd_count=0)
|
---|
63 |
|
---|
64 | #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
|
---|
65 |
|
---|
66 | struct timeval {
|
---|
67 | long tv_sec; /* seconds */
|
---|
68 | long tv_usec; /* and microseconds */
|
---|
69 | };
|
---|
70 |
|
---|
71 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
---|
72 | #define timercmp(tvp, uvp, cmp) \
|
---|
73 | ((tvp)->tv_sec cmp (uvp)->tv_sec || \
|
---|
74 | (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
|
---|
75 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
---|
76 |
|
---|
77 | #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
|
---|
78 | #define IOC_VOID 0x20000000 /* no parameters */
|
---|
79 | #define IOC_OUT 0x40000000 /* copy out parameters */
|
---|
80 | #define IOC_IN 0x80000000 /* copy in parameters */
|
---|
81 | #define IOC_INOUT (IOC_IN|IOC_OUT)
|
---|
82 | /* 0x20000000 distinguishes new &
|
---|
83 | old ioctl's */
|
---|
84 | #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
|
---|
85 |
|
---|
86 | #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
87 |
|
---|
88 | #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
89 |
|
---|
90 | #define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
|
---|
91 | #define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
|
---|
92 | #define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
|
---|
93 |
|
---|
94 | #define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
|
---|
95 | #define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
|
---|
96 | #define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
|
---|
97 | #define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
|
---|
98 | #define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
|
---|
99 |
|
---|
100 | struct hostent {
|
---|
101 | char * h_name;
|
---|
102 | char * * h_aliases;
|
---|
103 | short h_addrtype;
|
---|
104 | short h_length;
|
---|
105 | char * * h_addr_list;
|
---|
106 | #define h_addr h_addr_list[0]
|
---|
107 | };
|
---|
108 |
|
---|
109 | struct netent {
|
---|
110 | char * n_name;
|
---|
111 | char * * n_aliases;
|
---|
112 | short n_addrtype;
|
---|
113 | u_long n_net;
|
---|
114 | };
|
---|
115 |
|
---|
116 | struct servent {
|
---|
117 | char * s_name;
|
---|
118 | char * * s_aliases;
|
---|
119 | short s_port;
|
---|
120 | char * s_proto;
|
---|
121 | };
|
---|
122 |
|
---|
123 | struct protoent {
|
---|
124 | char * p_name;
|
---|
125 | char * * p_aliases;
|
---|
126 | short p_proto;
|
---|
127 | };
|
---|
128 |
|
---|
129 | #define IPPROTO_IP 0
|
---|
130 | #define IPPROTO_ICMP 1
|
---|
131 | #define IPPROTO_IGMP 2
|
---|
132 | #define IPPROTO_GGP 3
|
---|
133 | #define IPPROTO_TCP 6
|
---|
134 | #define IPPROTO_PUP 12
|
---|
135 | #define IPPROTO_UDP 17
|
---|
136 | #define IPPROTO_IDP 22
|
---|
137 | #define IPPROTO_ND 77
|
---|
138 |
|
---|
139 | #define IPPROTO_RAW 255
|
---|
140 | #define IPPROTO_MAX 256
|
---|
141 |
|
---|
142 | #define IPPORT_ECHO 7
|
---|
143 | #define IPPORT_DISCARD 9
|
---|
144 | #define IPPORT_SYSTAT 11
|
---|
145 | #define IPPORT_DAYTIME 13
|
---|
146 | #define IPPORT_NETSTAT 15
|
---|
147 | #define IPPORT_FTP 21
|
---|
148 | #define IPPORT_TELNET 23
|
---|
149 | #define IPPORT_SMTP 25
|
---|
150 | #define IPPORT_TIMESERVER 37
|
---|
151 | #define IPPORT_NAMESERVER 42
|
---|
152 | #define IPPORT_WHOIS 43
|
---|
153 | #define IPPORT_MTP 57
|
---|
154 |
|
---|
155 | #define IPPORT_TFTP 69
|
---|
156 | #define IPPORT_RJE 77
|
---|
157 | #define IPPORT_FINGER 79
|
---|
158 | #define IPPORT_TTYLINK 87
|
---|
159 | #define IPPORT_SUPDUP 95
|
---|
160 |
|
---|
161 | #define IPPORT_EXECSERVER 512
|
---|
162 | #define IPPORT_LOGINSERVER 513
|
---|
163 | #define IPPORT_CMDSERVER 514
|
---|
164 | #define IPPORT_EFSSERVER 520
|
---|
165 |
|
---|
166 | #define IPPORT_BIFFUDP 512
|
---|
167 | #define IPPORT_WHOSERVER 513
|
---|
168 | #define IPPORT_ROUTESERVER 520
|
---|
169 |
|
---|
170 | #define IPPORT_RESERVED 1024
|
---|
171 |
|
---|
172 | #define IMPLINK_IP 155
|
---|
173 | #define IMPLINK_LOWEXPER 156
|
---|
174 | #define IMPLINK_HIGHEXPER 158
|
---|
175 |
|
---|
176 | struct in_addr {
|
---|
177 | union {
|
---|
178 | struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
|
---|
179 | struct { u_short s_w1,s_w2; } S_un_w;
|
---|
180 | u_long S_addr;
|
---|
181 | } S_un;
|
---|
182 |
|
---|
183 | #define s_addr S_un.S_addr
|
---|
184 | #define s_host S_un.S_un_b.s_b2
|
---|
185 | #define s_net S_un.S_un_b.s_b1
|
---|
186 | #define s_imp S_un.S_un_w.s_w2
|
---|
187 | #define s_impno S_un.S_un_b.s_b4
|
---|
188 | #define s_lh S_un.S_un_b.s_b3
|
---|
189 | };
|
---|
190 |
|
---|
191 | #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
|
---|
192 | #define IN_CLASSA_NET 0xff000000
|
---|
193 | #define IN_CLASSA_NSHIFT 24
|
---|
194 | #define IN_CLASSA_HOST 0x00ffffff
|
---|
195 | #define IN_CLASSA_MAX 128
|
---|
196 |
|
---|
197 | #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
|
---|
198 | #define IN_CLASSB_NET 0xffff0000
|
---|
199 | #define IN_CLASSB_NSHIFT 16
|
---|
200 | #define IN_CLASSB_HOST 0x0000ffff
|
---|
201 | #define IN_CLASSB_MAX 65536
|
---|
202 |
|
---|
203 | #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
|
---|
204 | #define IN_CLASSC_NET 0xffffff00
|
---|
205 | #define IN_CLASSC_NSHIFT 8
|
---|
206 | #define IN_CLASSC_HOST 0x000000ff
|
---|
207 |
|
---|
208 | #define INADDR_ANY (u_long)0x00000000
|
---|
209 | #define INADDR_LOOPBACK 0x7f000001
|
---|
210 | #define INADDR_BROADCAST (u_long)0xffffffff
|
---|
211 | #define INADDR_NONE 0xffffffff
|
---|
212 |
|
---|
213 | struct sockaddr_in {
|
---|
214 | short sin_family;
|
---|
215 | u_short sin_port;
|
---|
216 | struct in_addr sin_addr;
|
---|
217 | char sin_zero[8];
|
---|
218 | };
|
---|
219 |
|
---|
220 | #define WSADESCRIPTION_LEN 256
|
---|
221 | #define WSASYS_STATUS_LEN 128
|
---|
222 |
|
---|
223 | typedef struct WSAData {
|
---|
224 | WORD wVersion;
|
---|
225 | WORD wHighVersion;
|
---|
226 | char szDescription[WSADESCRIPTION_LEN+1];
|
---|
227 | char szSystemStatus[WSASYS_STATUS_LEN+1];
|
---|
228 | unsigned short iMaxSockets;
|
---|
229 | unsigned short iMaxUdpDg;
|
---|
230 | char * lpVendorInfo;
|
---|
231 | } WSADATA;
|
---|
232 |
|
---|
233 | typedef WSADATA *LPWSADATA;
|
---|
234 |
|
---|
235 | #define IP_OPTIONS 1
|
---|
236 | #define IP_MULTICAST_IF 2
|
---|
237 | #define IP_MULTICAST_TTL 3
|
---|
238 | #define IP_MULTICAST_LOOP 4
|
---|
239 | #define IP_ADD_MEMBERSHIP 5
|
---|
240 | #define IP_DROP_MEMBERSHIP 6
|
---|
241 | #define IP_TTL 7
|
---|
242 | #define IP_TOS 8
|
---|
243 | #define IP_DONTFRAGMENT 9
|
---|
244 |
|
---|
245 |
|
---|
246 | #define IP_DEFAULT_MULTICAST_TTL 1
|
---|
247 | #define IP_DEFAULT_MULTICAST_LOOP 1
|
---|
248 | #define IP_MAX_MEMBERSHIPS 20
|
---|
249 |
|
---|
250 | struct ip_mreq {
|
---|
251 | struct in_addr imr_multiaddr;
|
---|
252 | struct in_addr imr_interface;
|
---|
253 | };
|
---|
254 |
|
---|
255 | #define INVALID_SOCKET (SOCKET)(~0)
|
---|
256 | #define SOCKET_ERROR (-1)
|
---|
257 |
|
---|
258 | #define SOCK_STREAM 1
|
---|
259 | #define SOCK_DGRAM 2
|
---|
260 | #define SOCK_RAW 3
|
---|
261 | #define SOCK_RDM 4
|
---|
262 | #define SOCK_SEQPACKET 5
|
---|
263 |
|
---|
264 | #define SO_DEBUG 0x0001
|
---|
265 | #define SO_ACCEPTCONN 0x0002
|
---|
266 | #define SO_REUSEADDR 0x0004
|
---|
267 | #define SO_KEEPALIVE 0x0008
|
---|
268 | #define SO_DONTROUTE 0x0010
|
---|
269 | #define SO_BROADCAST 0x0020
|
---|
270 | #define SO_USELOOPBACK 0x0040
|
---|
271 | #define SO_LINGER 0x0080
|
---|
272 | #define SO_OOBINLINE 0x0100
|
---|
273 |
|
---|
274 | #define SO_DONTLINGER (u_int)(~SO_LINGER)
|
---|
275 |
|
---|
276 | #define SO_SNDBUF 0x1001
|
---|
277 | #define SO_RCVBUF 0x1002
|
---|
278 | #define SO_SNDLOWAT 0x1003
|
---|
279 | #define SO_RCVLOWAT 0x1004
|
---|
280 | #define SO_SNDTIMEO 0x1005
|
---|
281 | #define SO_RCVTIMEO 0x1006
|
---|
282 | #define SO_ERROR 0x1007
|
---|
283 | #define SO_TYPE 0x1008
|
---|
284 |
|
---|
285 | #define SO_CONNDATA 0x7000
|
---|
286 | #define SO_CONNOPT 0x7001
|
---|
287 | #define SO_DISCDATA 0x7002
|
---|
288 | #define SO_DISCOPT 0x7003
|
---|
289 | #define SO_CONNDATALEN 0x7004
|
---|
290 | #define SO_CONNOPTLEN 0x7005
|
---|
291 | #define SO_DISCDATALEN 0x7006
|
---|
292 | #define SO_DISCOPTLEN 0x7007
|
---|
293 |
|
---|
294 | #define SO_OPENTYPE 0x7008
|
---|
295 |
|
---|
296 | #define SO_SYNCHRONOUS_ALERT 0x10
|
---|
297 | #define SO_SYNCHRONOUS_NONALERT 0x20
|
---|
298 |
|
---|
299 | #define SO_MAXDG 0x7009
|
---|
300 | #define SO_MAXPATHDG 0x700A
|
---|
301 | #define SO_UPDATE_ACCEPT_CONTEXT 0x700B
|
---|
302 | #define SO_CONNECT_TIME 0x700C
|
---|
303 |
|
---|
304 | #define TCP_NODELAY 0x0001
|
---|
305 | #define TCP_BSDURGENT 0x7000
|
---|
306 |
|
---|
307 | #define AF_UNSPEC 0
|
---|
308 | #define AF_UNIX 1
|
---|
309 | #define AF_INET 2
|
---|
310 | #define AF_IMPLINK 3
|
---|
311 | #define AF_PUP 4
|
---|
312 | #define AF_CHAOS 5
|
---|
313 | #define AF_IPX 6
|
---|
314 | #define AF_NS 6
|
---|
315 | #define AF_ISO 7
|
---|
316 | #define AF_OSI AF_ISO
|
---|
317 | #define AF_ECMA 8
|
---|
318 | #define AF_DATAKIT 9
|
---|
319 | #define AF_CCITT 10
|
---|
320 | #define AF_SNA 11
|
---|
321 | #define AF_DECnet 12
|
---|
322 | #define AF_DLI 13
|
---|
323 | #define AF_LAT 14
|
---|
324 | #define AF_HYLINK 15
|
---|
325 | #define AF_APPLETALK 16
|
---|
326 | #define AF_NETBIOS 17
|
---|
327 | #define AF_VOICEVIEW 18
|
---|
328 | #define AF_FIREFOX 19
|
---|
329 | #define AF_UNKNOWN1 20
|
---|
330 | #define AF_BAN 21
|
---|
331 |
|
---|
332 | #define AF_MAX 22
|
---|
333 |
|
---|
334 | struct sockaddr {
|
---|
335 | u_short sa_family;
|
---|
336 | char sa_data[14];
|
---|
337 | };
|
---|
338 |
|
---|
339 | struct sockproto {
|
---|
340 | u_short sp_family; /* address family */
|
---|
341 | u_short sp_protocol; /* protocol */
|
---|
342 | };
|
---|
343 |
|
---|
344 | #define PF_UNSPEC AF_UNSPEC
|
---|
345 | #define PF_UNIX AF_UNIX
|
---|
346 | #define PF_INET AF_INET
|
---|
347 | #define PF_IMPLINK AF_IMPLINK
|
---|
348 | #define PF_PUP AF_PUP
|
---|
349 | #define PF_CHAOS AF_CHAOS
|
---|
350 | #define PF_NS AF_NS
|
---|
351 | #define PF_IPX AF_IPX
|
---|
352 | #define PF_ISO AF_ISO
|
---|
353 | #define PF_OSI AF_OSI
|
---|
354 | #define PF_ECMA AF_ECMA
|
---|
355 | #define PF_DATAKIT AF_DATAKIT
|
---|
356 | #define PF_CCITT AF_CCITT
|
---|
357 | #define PF_SNA AF_SNA
|
---|
358 | #define PF_DECnet AF_DECnet
|
---|
359 | #define PF_DLI AF_DLI
|
---|
360 | #define PF_LAT AF_LAT
|
---|
361 | #define PF_HYLINK AF_HYLINK
|
---|
362 | #define PF_APPLETALK AF_APPLETALK
|
---|
363 | #define PF_VOICEVIEW AF_VOICEVIEW
|
---|
364 | #define PF_FIREFOX AF_FIREFOX
|
---|
365 | #define PF_UNKNOWN1 AF_UNKNOWN1
|
---|
366 | #define PF_BAN AF_BAN
|
---|
367 |
|
---|
368 | #define PF_MAX AF_MAX
|
---|
369 |
|
---|
370 | struct linger {
|
---|
371 | u_short l_onoff; /* option on/off */
|
---|
372 | u_short l_linger; /* linger time */
|
---|
373 | };
|
---|
374 |
|
---|
375 | #define SOL_SOCKET 0xffff /* options for socket level */
|
---|
376 |
|
---|
377 | #define SOMAXCONN 5
|
---|
378 |
|
---|
379 | #define MSG_OOB 0x1 /* process out-of-band data */
|
---|
380 | #define MSG_PEEK 0x2 /* peek at incoming message */
|
---|
381 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
---|
382 |
|
---|
383 | #define MSG_MAXIOVLEN 16
|
---|
384 |
|
---|
385 | #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
|
---|
386 |
|
---|
387 | #define MAXGETHOSTSTRUCT 1024
|
---|
388 |
|
---|
389 | #ifndef __WINSOCK2API__
|
---|
390 | #define FD_READ 0x01
|
---|
391 | #define FD_WRITE 0x02
|
---|
392 | #define FD_OOB 0x04
|
---|
393 | #define FD_ACCEPT 0x08
|
---|
394 | #define FD_CONNECT 0x10
|
---|
395 | #define FD_CLOSE 0x20
|
---|
396 | #endif
|
---|
397 |
|
---|
398 | #define WSABASEERR 10000
|
---|
399 |
|
---|
400 | #define WSAEINTR (WSABASEERR+4)
|
---|
401 | #define WSAEBADF (WSABASEERR+9)
|
---|
402 | #define WSAEACCES (WSABASEERR+13)
|
---|
403 | #define WSAEFAULT (WSABASEERR+14)
|
---|
404 | #define WSAEINVAL (WSABASEERR+22)
|
---|
405 | #define WSAEMFILE (WSABASEERR+24)
|
---|
406 |
|
---|
407 | #define WSAEWOULDBLOCK (WSABASEERR+35)
|
---|
408 | #define WSAEINPROGRESS (WSABASEERR+36)
|
---|
409 | #define WSAEALREADY (WSABASEERR+37)
|
---|
410 | #define WSAENOTSOCK (WSABASEERR+38)
|
---|
411 | #define WSAEDESTADDRREQ (WSABASEERR+39)
|
---|
412 | #define WSAEMSGSIZE (WSABASEERR+40)
|
---|
413 | #define WSAEPROTOTYPE (WSABASEERR+41)
|
---|
414 | #define WSAENOPROTOOPT (WSABASEERR+42)
|
---|
415 | #define WSAEPROTONOSUPPORT (WSABASEERR+43)
|
---|
416 | #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
|
---|
417 | #define WSAEOPNOTSUPP (WSABASEERR+45)
|
---|
418 | #define WSAEPFNOSUPPORT (WSABASEERR+46)
|
---|
419 | #define WSAEAFNOSUPPORT (WSABASEERR+47)
|
---|
420 | #define WSAEADDRINUSE (WSABASEERR+48)
|
---|
421 | #define WSAEADDRNOTAVAIL (WSABASEERR+49)
|
---|
422 | #define WSAENETDOWN (WSABASEERR+50)
|
---|
423 | #define WSAENETUNREACH (WSABASEERR+51)
|
---|
424 | #define WSAENETRESET (WSABASEERR+52)
|
---|
425 | #define WSAECONNABORTED (WSABASEERR+53)
|
---|
426 | #define WSAECONNRESET (WSABASEERR+54)
|
---|
427 | #define WSAENOBUFS (WSABASEERR+55)
|
---|
428 | #define WSAEISCONN (WSABASEERR+56)
|
---|
429 | #define WSAENOTCONN (WSABASEERR+57)
|
---|
430 | #define WSAESHUTDOWN (WSABASEERR+58)
|
---|
431 | #define WSAETOOMANYREFS (WSABASEERR+59)
|
---|
432 | #define WSAETIMEDOUT (WSABASEERR+60)
|
---|
433 | #define WSAECONNREFUSED (WSABASEERR+61)
|
---|
434 | #define WSAELOOP (WSABASEERR+62)
|
---|
435 | #define WSAENAMETOOLONG (WSABASEERR+63)
|
---|
436 | #define WSAEHOSTDOWN (WSABASEERR+64)
|
---|
437 | #define WSAEHOSTUNREACH (WSABASEERR+65)
|
---|
438 | #define WSAENOTEMPTY (WSABASEERR+66)
|
---|
439 | #define WSAEPROCLIM (WSABASEERR+67)
|
---|
440 | #define WSAEUSERS (WSABASEERR+68)
|
---|
441 | #define WSAEDQUOT (WSABASEERR+69)
|
---|
442 | #define WSAESTALE (WSABASEERR+70)
|
---|
443 | #define WSAEREMOTE (WSABASEERR+71)
|
---|
444 |
|
---|
445 | #define WSAEDISCON (WSABASEERR+101)
|
---|
446 |
|
---|
447 | #define WSASYSNOTREADY (WSABASEERR+91)
|
---|
448 | #define WSAVERNOTSUPPORTED (WSABASEERR+92)
|
---|
449 | #define WSANOTINITIALISED (WSABASEERR+93)
|
---|
450 |
|
---|
451 | #define h_errno WSAGetLastError()
|
---|
452 |
|
---|
453 | #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
|
---|
454 | #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
|
---|
455 |
|
---|
456 | #define WSATRY_AGAIN (WSABASEERR+1002)
|
---|
457 | #define TRY_AGAIN WSATRY_AGAIN
|
---|
458 |
|
---|
459 | #define WSANO_RECOVERY (WSABASEERR+1003)
|
---|
460 | #define NO_RECOVERY WSANO_RECOVERY
|
---|
461 |
|
---|
462 | #define WSANO_DATA (WSABASEERR+1004)
|
---|
463 | #define NO_DATA WSANO_DATA
|
---|
464 |
|
---|
465 | #define WSANO_ADDRESS WSANO_DATA
|
---|
466 | #define NO_ADDRESS WSANO_ADDRESS
|
---|
467 |
|
---|
468 | #ifdef __cplusplus
|
---|
469 | extern "C" {
|
---|
470 | #endif
|
---|
471 |
|
---|
472 | SOCKET WIN32API accept (SOCKET s, struct sockaddr *addr,
|
---|
473 | int *addrlen);
|
---|
474 |
|
---|
475 | int WIN32API bind (SOCKET s, const struct sockaddr *addr, int namelen);
|
---|
476 |
|
---|
477 | int WIN32API closesocket (SOCKET s);
|
---|
478 |
|
---|
479 | int WIN32API connect (SOCKET s, const struct sockaddr *name, int namelen);
|
---|
480 |
|
---|
481 | int WIN32API ioctlsocket (SOCKET s, long cmd, u_long *argp);
|
---|
482 |
|
---|
483 | int WIN32API getpeername (SOCKET s, struct sockaddr *name,
|
---|
484 | int * namelen);
|
---|
485 |
|
---|
486 | int WIN32API getsockname (SOCKET s, struct sockaddr *name,
|
---|
487 | int * namelen);
|
---|
488 |
|
---|
489 | int WIN32API getsockopt (SOCKET s, int level, int optname,
|
---|
490 | char * optval, int *optlen);
|
---|
491 |
|
---|
492 | u_long WIN32API htonl (u_long hostlong);
|
---|
493 |
|
---|
494 | u_short WIN32API htons (u_short hostshort);
|
---|
495 |
|
---|
496 | unsigned long WIN32API inet_addr (const char * cp);
|
---|
497 |
|
---|
498 | char * WIN32API inet_ntoa (struct in_addr in);
|
---|
499 |
|
---|
500 | int WIN32API listen (SOCKET s, int backlog);
|
---|
501 |
|
---|
502 | u_long WIN32API ntohl (u_long netlong);
|
---|
503 |
|
---|
504 | u_short WIN32API ntohs (u_short netshort);
|
---|
505 |
|
---|
506 | int WIN32API recv (SOCKET s, char * buf, int len, int flags);
|
---|
507 |
|
---|
508 | int WIN32API recvfrom (SOCKET s, char * buf, int len, int flags,
|
---|
509 | struct sockaddr *from, int * fromlen);
|
---|
510 |
|
---|
511 | int WIN32API select (int nfds, fd_set *readfds, fd_set *writefds,
|
---|
512 | fd_set *exceptfds, const struct timeval *timeout);
|
---|
513 |
|
---|
514 | int WIN32API send (SOCKET s, const char * buf, int len, int flags);
|
---|
515 |
|
---|
516 | int WIN32API sendto (SOCKET s, const char * buf, int len, int flags,
|
---|
517 | const struct sockaddr *to, int tolen);
|
---|
518 |
|
---|
519 | int WIN32API setsockopt (SOCKET s, int level, int optname,
|
---|
520 | const char * optval, int optlen);
|
---|
521 |
|
---|
522 | int WIN32API shutdown (SOCKET s, int how);
|
---|
523 |
|
---|
524 | SOCKET WIN32API socket (int af, int type, int protocol);
|
---|
525 |
|
---|
526 | /* Database function prototypes */
|
---|
527 |
|
---|
528 | struct hostent * WIN32API gethostbyaddr(const char * addr,
|
---|
529 | int len, int type);
|
---|
530 |
|
---|
531 | struct hostent * WIN32API gethostbyname(const char * name);
|
---|
532 |
|
---|
533 | int WIN32API gethostname (char * name, int namelen);
|
---|
534 |
|
---|
535 | struct servent * WIN32API getservbyport(int port, const char * proto);
|
---|
536 |
|
---|
537 | struct servent * WIN32API getservbyname(const char * name,
|
---|
538 | const char * proto);
|
---|
539 |
|
---|
540 | struct protoent * WIN32API getprotobynumber(int proto);
|
---|
541 |
|
---|
542 | struct protoent * WIN32API getprotobyname(const char * name);
|
---|
543 |
|
---|
544 | /* Microsoft Windows Extension function prototypes */
|
---|
545 |
|
---|
546 | int WIN32API WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
|
---|
547 |
|
---|
548 | int WIN32API WSACleanup(void);
|
---|
549 |
|
---|
550 | void WIN32API WSASetLastError(int iError);
|
---|
551 |
|
---|
552 | int WIN32API WSAGetLastError(void);
|
---|
553 |
|
---|
554 | BOOL WIN32API WSAIsBlocking(void);
|
---|
555 |
|
---|
556 | int WIN32API WSAUnhookBlockingHook(void);
|
---|
557 |
|
---|
558 | FARPROC WIN32API WSASetBlockingHook(FARPROC lpBlockFunc);
|
---|
559 |
|
---|
560 | int WIN32API WSACancelBlockingCall(void);
|
---|
561 |
|
---|
562 | HANDLE WIN32API WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
|
---|
563 | const char * name,
|
---|
564 | const char * proto,
|
---|
565 | char * buf, int buflen);
|
---|
566 |
|
---|
567 | HANDLE WIN32API WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
|
---|
568 | const char * proto, char * buf,
|
---|
569 | int buflen);
|
---|
570 |
|
---|
571 | HANDLE WIN32API WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
|
---|
572 | const char * name, char * buf,
|
---|
573 | int buflen);
|
---|
574 |
|
---|
575 | HANDLE WIN32API WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
|
---|
576 | int number, char * buf,
|
---|
577 | int buflen);
|
---|
578 |
|
---|
579 | HANDLE WIN32API WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
|
---|
580 | const char * name, char * buf,
|
---|
581 | int buflen);
|
---|
582 |
|
---|
583 | HANDLE WIN32API WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
|
---|
584 | const char * addr, int len, int type,
|
---|
585 | char * buf, int buflen);
|
---|
586 |
|
---|
587 | int WIN32API WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
|
---|
588 |
|
---|
589 | int WIN32API WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
|
---|
590 | long lEvent);
|
---|
591 |
|
---|
592 | int WIN32API WSARecvEx (SOCKET s, char * buf, int len, int *flags);
|
---|
593 |
|
---|
594 | typedef struct _TRANSMIT_FILE_BUFFERS {
|
---|
595 | PVOID Head;
|
---|
596 | DWORD HeadLength;
|
---|
597 | PVOID Tail;
|
---|
598 | DWORD TailLength;
|
---|
599 | } TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
|
---|
600 |
|
---|
601 | #define TF_DISCONNECT 0x01
|
---|
602 | #define TF_REUSE_SOCKET 0x02
|
---|
603 | #define TF_WRITE_BEHIND 0x04
|
---|
604 |
|
---|
605 | BOOL WIN32API TransmitFile (
|
---|
606 | SOCKET hSocket,
|
---|
607 | HANDLE hFile,
|
---|
608 | DWORD nNumberOfBytesToWrite,
|
---|
609 | DWORD nNumberOfBytesPerSend,
|
---|
610 | LPOVERLAPPED lpOverlapped,
|
---|
611 | LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
---|
612 | DWORD dwReserved
|
---|
613 | );
|
---|
614 |
|
---|
615 | BOOL WIN32API AcceptEx (
|
---|
616 | SOCKET sListenSocket,
|
---|
617 | SOCKET sAcceptSocket,
|
---|
618 | PVOID lpOutputBuffer,
|
---|
619 | DWORD dwReceiveDataLength,
|
---|
620 | DWORD dwLocalAddressLength,
|
---|
621 | DWORD dwRemoteAddressLength,
|
---|
622 | LPDWORD lpdwBytesReceived,
|
---|
623 | LPOVERLAPPED lpOverlapped
|
---|
624 | );
|
---|
625 |
|
---|
626 | VOID WIN32API GetAcceptExSockaddrs (
|
---|
627 | PVOID lpOutputBuffer,
|
---|
628 | DWORD dwReceiveDataLength,
|
---|
629 | DWORD dwLocalAddressLength,
|
---|
630 | DWORD dwRemoteAddressLength,
|
---|
631 | struct sockaddr **LocalSockaddr,
|
---|
632 | LPINT LocalSockaddrLength,
|
---|
633 | struct sockaddr **RemoteSockaddr,
|
---|
634 | LPINT RemoteSockaddrLength
|
---|
635 | );
|
---|
636 |
|
---|
637 | #ifdef __cplusplus
|
---|
638 | }
|
---|
639 | #endif
|
---|
640 |
|
---|
641 | typedef struct sockaddr SOCKADDR;
|
---|
642 | typedef struct sockaddr *PSOCKADDR;
|
---|
643 | typedef struct sockaddr *LPSOCKADDR;
|
---|
644 |
|
---|
645 | typedef struct sockaddr_in SOCKADDR_IN;
|
---|
646 | typedef struct sockaddr_in *PSOCKADDR_IN;
|
---|
647 | typedef struct sockaddr_in *LPSOCKADDR_IN;
|
---|
648 |
|
---|
649 | typedef struct linger LINGER;
|
---|
650 | typedef struct linger *PLINGER;
|
---|
651 | typedef struct linger *LPLINGER;
|
---|
652 |
|
---|
653 | typedef struct in_addr IN_ADDR;
|
---|
654 | typedef struct in_addr *PIN_ADDR;
|
---|
655 | typedef struct in_addr *LPIN_ADDR;
|
---|
656 |
|
---|
657 | typedef struct fd_set FD_SET;
|
---|
658 | typedef struct fd_set *PFD_SET;
|
---|
659 | typedef struct fd_set *LPFD_SET;
|
---|
660 |
|
---|
661 | typedef struct hostent HOSTENT;
|
---|
662 | typedef struct hostent *PHOSTENT;
|
---|
663 | typedef struct hostent *LPHOSTENT;
|
---|
664 |
|
---|
665 | typedef struct servent SERVENT;
|
---|
666 | typedef struct servent *PSERVENT;
|
---|
667 | typedef struct servent *LPSERVENT;
|
---|
668 |
|
---|
669 | typedef struct protoent PROTOENT;
|
---|
670 | typedef struct protoent *PPROTOENT;
|
---|
671 | typedef struct protoent *LPPROTOENT;
|
---|
672 |
|
---|
673 | typedef struct timeval TIMEVAL;
|
---|
674 | typedef struct timeval *PTIMEVAL;
|
---|
675 | typedef struct timeval *LPTIMEVAL;
|
---|
676 |
|
---|
677 | #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
|
---|
678 | #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
---|
679 | #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
|
---|
680 | #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
|
---|
681 | #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
|
---|
682 | #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
|
---|
683 |
|
---|
684 | #endif // _WINSOCKAPI_
|
---|
685 |
|
---|
686 |
|
---|