OSDN Git Service

d717585b617d222cb647941546cc09b5cb928a23
[mingw/mingw-org-wsl.git] / include / winsock.h
1 /**
2  * @file winsock.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _WINSOCK_H
25 #define _WINSOCK_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN95)
30 #warning WARNING Winsock.h is included instead of winsock2.h.
31 #endif
32
33 /*
34   Definitions for winsock 1.1
35   
36   Portions Copyright (c) 1980, 1983, 1988, 1993
37   The Regents of the University of California.  All rights reserved.
38
39   Portions Copyright (c) 1993 by Digital Equipment Corporation.
40  */
41
42 #define _GNU_H_WINDOWS32_SOCKETS
43
44 #include <windows.h>
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 #if !defined ( _BSDTYPES_DEFINED )
51 /* also defined in gmon.h and in cygwin's sys/types */
52 typedef unsigned char   u_char;
53 typedef unsigned short  u_short;
54 typedef unsigned int    u_int;
55 typedef unsigned long   u_long;
56 #define _BSDTYPES_DEFINED
57 #endif /* !defined  _BSDTYPES_DEFINED */
58
59 typedef u_int   SOCKET;
60
61 #ifndef FD_SETSIZE
62 #define FD_SETSIZE      64
63 #endif
64
65 /* shutdown() how types */
66 #define SD_RECEIVE      0x00
67 #define SD_SEND         0x01
68 #define SD_BOTH         0x02
69
70 #ifndef _SYS_TYPES_FD_SET
71 /* fd_set may have be defined by the newlib <sys/types.h>
72  * if  __USE_W32_SOCKETS not defined.
73  */
74
75 #ifdef fd_set
76 #undef fd_set
77 #endif
78
79 typedef struct fd_set {
80         u_int   fd_count;
81         SOCKET  fd_array[FD_SETSIZE];
82 } fd_set;
83 int PASCAL __WSAFDIsSet(SOCKET,fd_set*);
84
85 #ifndef FD_CLR
86 #define FD_CLR(fd,set) do { u_int __i;\
87 for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) {\
88         if (((fd_set *)(set))->fd_array[__i] == (fd)) {\
89         while (__i < ((fd_set *)(set))->fd_count-1) {\
90                 ((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i+1];\
91                 __i++;\
92         }\
93         ((fd_set*)(set))->fd_count--;\
94         break;\
95         }\
96 }\
97 } while (0)
98 #endif
99
100 #ifndef FD_SET
101 #define FD_SET(fd, set) do { \
102     if (((fd_set *)(set))->fd_count < FD_SETSIZE) \
103         ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=(fd);\
104 }while (0)
105 #endif
106
107 #ifndef FD_ZERO
108 #define FD_ZERO(set) (((fd_set *)(set))->fd_count=0)
109 #endif
110
111 #ifndef FD_ISSET
112 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
113 #endif
114
115 #elif !defined(USE_SYS_TYPES_FD_SET)
116 #warning "fd_set and associated macros have been defined in sys/types.  \
117     This can cause runtime problems with W32 sockets" 
118 #endif /* ndef _SYS_TYPES_FD_SET */
119
120 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
121
122 #ifndef _TIMEVAL_DEFINED /* also in sys/time.h */
123 #define _TIMEVAL_DEFINED
124 struct timeval {
125         long    tv_sec;
126         long    tv_usec;
127 };
128 #define timerisset(tvp)  ((tvp)->tv_sec || (tvp)->tv_usec)
129 #define timercmp(tvp, uvp, cmp) \
130         (((tvp)->tv_sec != (uvp)->tv_sec) ? \
131         ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
132         ((tvp)->tv_usec cmp (uvp)->tv_usec))
133 #define timerclear(tvp)  (tvp)->tv_sec = (tvp)->tv_usec = 0
134 #endif /* _TIMEVAL_DEFINED */
135 struct  hostent {
136         char    *h_name;
137         char    **h_aliases;
138         short   h_addrtype;
139         short   h_length;
140         char    **h_addr_list;
141 #define h_addr h_addr_list[0]
142 };
143 struct linger {
144         u_short l_onoff;
145         u_short l_linger;
146 };
147 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
148
149 #define IOCPARM_MASK    0x7f
150 #define IOC_VOID        0x20000000
151 #define IOC_OUT 0x40000000
152 #define IOC_IN  0x80000000
153 #define IOC_INOUT       (IOC_IN|IOC_OUT)
154
155 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
156 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
157 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
158 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
159 #define FIONBIO _IOW('f', 126, u_long)
160 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
161
162 #define FIONREAD        _IOR('f', 127, u_long)
163 #define FIOASYNC        _IOW('f', 125, u_long)
164 #define SIOCSHIWAT      _IOW('s',  0, u_long)
165 #define SIOCGHIWAT      _IOR('s',  1, u_long)
166 #define SIOCSLOWAT      _IOW('s',  2, u_long)
167 #define SIOCGLOWAT      _IOR('s',  3, u_long)
168 #define SIOCATMARK      _IOR('s',  7, u_long)
169
170 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
171 struct netent {
172         char    * n_name;
173         char    **n_aliases;
174         short   n_addrtype;
175         u_long n_net;
176 };
177 struct  servent {
178         char    *s_name;
179         char    **s_aliases;
180         short   s_port;
181         char    *s_proto;
182 };
183 struct  protoent {
184         char    *p_name;
185         char    **p_aliases;
186         short   p_proto;
187 };
188 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
189
190 #define IPPROTO_IP      0
191 #define IPPROTO_ICMP    1
192 #define IPPROTO_IGMP 2
193 #define IPPROTO_GGP 3
194 #define IPPROTO_TCP     6
195 #define IPPROTO_PUP     12
196 #define IPPROTO_UDP     17
197 #define IPPROTO_IDP     22
198 #define IPPROTO_ND      77
199 #define IPPROTO_RAW     255
200 #define IPPROTO_MAX     256
201 #define IPPORT_ECHO     7
202 #define IPPORT_DISCARD  9
203 #define IPPORT_SYSTAT   11
204 #define IPPORT_DAYTIME  13
205 #define IPPORT_NETSTAT  15
206 #define IPPORT_FTP      21
207 #define IPPORT_TELNET   23
208 #define IPPORT_SMTP     25
209 #define IPPORT_TIMESERVER 37
210 #define IPPORT_NAMESERVER 42
211 #define IPPORT_WHOIS    43
212 #define IPPORT_MTP      57
213 #define IPPORT_TFTP     69
214 #define IPPORT_RJE      77
215 #define IPPORT_FINGER   79
216 #define IPPORT_TTYLINK  87
217 #define IPPORT_SUPDUP   95
218 #define IPPORT_EXECSERVER       512
219 #define IPPORT_LOGINSERVER      513
220 #define IPPORT_CMDSERVER        514
221 #define IPPORT_EFSSERVER        520
222 #define IPPORT_BIFFUDP  512
223 #define IPPORT_WHOSERVER        513
224 #define IPPORT_ROUTESERVER      520
225 #define IPPORT_RESERVED 1024
226 #define IMPLINK_IP      155
227 #define IMPLINK_LOWEXPER        156
228 #define IMPLINK_HIGHEXPER       158
229 struct in_addr {
230         union {
231                 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
232                 struct { u_short s_w1,s_w2; } S_un_w;
233                 u_long S_addr;
234         } S_un;
235 #define s_addr  S_un.S_addr
236 #define s_host  S_un.S_un_b.s_b2
237 #define s_net   S_un.S_un_b.s_b1
238 #define s_imp   S_un.S_un_w.s_w2
239 #define s_impno S_un.S_un_b.s_b4
240 #define s_lh    S_un.S_un_b.s_b3
241 };
242 #define IN_CLASSA(i)    (((long)(i)&0x80000000) == 0)
243 #define IN_CLASSA_NET   0xff000000
244 #define IN_CLASSA_NSHIFT        24
245 #define IN_CLASSA_HOST  0x00ffffff
246 #define IN_CLASSA_MAX   128
247 #define IN_CLASSB(i)    (((long)(i)&0xc0000000)==0x80000000)
248 #define IN_CLASSB_NET      0xffff0000
249 #define IN_CLASSB_NSHIFT        16
250 #define IN_CLASSB_HOST    0x0000ffff
251 #define IN_CLASSB_MAX      65536
252 #define IN_CLASSC(i)    (((long)(i)&0xe0000000)==0xc0000000)
253 #define IN_CLASSC_NET      0xffffff00
254 #define IN_CLASSC_NSHIFT        8
255 #define IN_CLASSC_HOST    0xff
256 #define INADDR_ANY            (u_long)0
257 #define INADDR_LOOPBACK  0x7f000001
258 #define INADDR_BROADCAST        (u_long)0xffffffff
259 #define INADDR_NONE     0xffffffff
260 struct sockaddr_in {
261         short   sin_family;
262         u_short sin_port;
263         struct  in_addr sin_addr;
264         char    sin_zero[8];
265 };
266 #define WSADESCRIPTION_LEN      256
267 #define WSASYS_STATUS_LEN       128
268 typedef struct WSAData {
269         WORD    wVersion;
270         WORD    wHighVersion;
271         char    szDescription[WSADESCRIPTION_LEN+1];
272         char    szSystemStatus[WSASYS_STATUS_LEN+1];
273         unsigned short  iMaxSockets;
274         unsigned short  iMaxUdpDg;
275         char *  lpVendorInfo;
276 } WSADATA;
277 typedef WSADATA *LPWSADATA;
278
279 #ifndef __INSIDE_MSYS__
280 #define IP_OPTIONS      1
281 #define SO_DEBUG        1
282 #define SO_ACCEPTCONN   2
283 #define SO_REUSEADDR    4
284 #define SO_KEEPALIVE    8
285 #define SO_DONTROUTE    16
286 #define SO_BROADCAST    32
287 #define SO_USELOOPBACK  64
288 #define SO_LINGER       128
289 #define SO_OOBINLINE    256
290 #define SO_DONTLINGER   (u_int)(~SO_LINGER)
291 #define SO_SNDBUF       0x1001
292 #define SO_RCVBUF       0x1002
293 #define SO_SNDLOWAT     0x1003
294 #define SO_RCVLOWAT     0x1004
295 #define SO_SNDTIMEO     0x1005
296 #define SO_RCVTIMEO     0x1006
297 #define SO_ERROR        0x1007
298 #define SO_TYPE 0x1008
299 #endif /* !__INSIDE_MSYS__ */
300
301 /*
302  * Note that the next 5 IP defines are specific to WinSock 1.1 (wsock32.dll).
303  * They will cause errors or unexpected results if used with the
304  * (gs)etsockopts exported from the WinSock 2 lib, ws2_32.dll. Refer ws2tcpip.h.
305  */         
306 #define IP_MULTICAST_IF 2
307 #define IP_MULTICAST_TTL        3
308 #define IP_MULTICAST_LOOP       4
309 #define IP_ADD_MEMBERSHIP       5
310 #define IP_DROP_MEMBERSHIP  6
311
312 #define IP_DEFAULT_MULTICAST_TTL   1
313 #define IP_DEFAULT_MULTICAST_LOOP  1
314 #define IP_MAX_MEMBERSHIPS       20
315 struct ip_mreq {
316         struct in_addr imr_multiaddr;
317         struct in_addr imr_interface;
318 };
319 #define INVALID_SOCKET (SOCKET)(~0)
320 #define SOCKET_ERROR    (-1)
321 #define SOCK_STREAM     1
322 #define SOCK_DGRAM      2
323 #define SOCK_RAW        3
324 #define SOCK_RDM        4
325 #define SOCK_SEQPACKET  5
326 #define TCP_NODELAY     0x0001
327 #define AF_UNSPEC       0
328 #define AF_UNIX 1
329 #define AF_INET 2
330 #define AF_IMPLINK      3
331 #define AF_PUP  4
332 #define AF_CHAOS        5
333 #define AF_IPX  6
334 #define AF_NS   6
335 #define AF_ISO  7
336 #define AF_OSI  AF_ISO
337 #define AF_ECMA 8
338 #define AF_DATAKIT      9
339 #define AF_CCITT        10
340 #define AF_SNA  11
341 #define AF_DECnet       12
342 #define AF_DLI  13
343 #define AF_LAT  14
344 #define AF_HYLINK       15
345 #define AF_APPLETALK    16
346 #define AF_NETBIOS      17
347 #define AF_VOICEVIEW    18
348 #define AF_FIREFOX      19
349 #define AF_UNKNOWN1     20
350 #define AF_BAN  21
351 #define AF_ATM  22
352 #define AF_INET6        23
353
354 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
355 #define AF_MAX  24
356 struct sockaddr {
357         u_short sa_family;
358         char    sa_data[14];
359 };
360 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
361
362 struct sockproto {
363         u_short sp_family;
364         u_short sp_protocol;
365 };
366 #define PF_UNSPEC       AF_UNSPEC
367 #define PF_UNIX AF_UNIX
368 #define PF_INET AF_INET
369 #define PF_IMPLINK      AF_IMPLINK
370 #define PF_PUP  AF_PUP
371 #define PF_CHAOS        AF_CHAOS
372 #define PF_NS   AF_NS
373 #define PF_IPX  AF_IPX
374 #define PF_ISO  AF_ISO
375 #define PF_OSI  AF_OSI
376 #define PF_ECMA AF_ECMA
377 #define PF_DATAKIT      AF_DATAKIT
378 #define PF_CCITT        AF_CCITT
379 #define PF_SNA  AF_SNA
380 #define PF_DECnet       AF_DECnet
381 #define PF_DLI  AF_DLI
382 #define PF_LAT  AF_LAT
383 #define PF_HYLINK       AF_HYLINK
384 #define PF_APPLETALK    AF_APPLETALK
385 #define PF_VOICEVIEW    AF_VOICEVIEW
386 #define PF_FIREFOX      AF_FIREFOX
387 #define PF_UNKNOWN1     AF_UNKNOWN1
388 #define PF_BAN  AF_BAN
389 #define PF_ATM  AF_ATM
390 #define PF_INET6        AF_INET6
391 #define PF_MAX  AF_MAX
392 #define SOL_SOCKET      0xffff
393 #define SOMAXCONN       5
394
395 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
396 #define MSG_OOB 1
397 #define MSG_PEEK        2
398 #define MSG_DONTROUTE   4
399 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
400
401 #define MSG_MAXIOVLEN   16
402 #define MSG_PARTIAL     0x8000
403 #define MAXGETHOSTSTRUCT        1024
404 #define FD_READ 1
405 #define FD_WRITE        2
406 #define FD_OOB  4
407 #define FD_ACCEPT       8
408 #define FD_CONNECT      16
409 #define FD_CLOSE        32
410
411 #ifndef WSABASEERR
412 #define WSABASEERR      10000
413 #define WSAEINTR        (WSABASEERR+4)
414 #define WSAEBADF        (WSABASEERR+9)
415 #define WSAEACCES       (WSABASEERR+13)
416 #define WSAEFAULT       (WSABASEERR+14)
417 #define WSAEINVAL       (WSABASEERR+22)
418 #define WSAEMFILE       (WSABASEERR+24)
419 #define WSAEWOULDBLOCK  (WSABASEERR+35)
420 #define WSAEINPROGRESS  (WSABASEERR+36)
421 #define WSAEALREADY     (WSABASEERR+37)
422 #define WSAENOTSOCK     (WSABASEERR+38)
423 #define WSAEDESTADDRREQ (WSABASEERR+39)
424 #define WSAEMSGSIZE     (WSABASEERR+40)
425 #define WSAEPROTOTYPE   (WSABASEERR+41)
426 #define WSAENOPROTOOPT  (WSABASEERR+42)
427 #define WSAEPROTONOSUPPORT      (WSABASEERR+43)
428 #define WSAESOCKTNOSUPPORT      (WSABASEERR+44)
429 #define WSAEOPNOTSUPP   (WSABASEERR+45)
430 #define WSAEPFNOSUPPORT (WSABASEERR+46)
431 #define WSAEAFNOSUPPORT (WSABASEERR+47)
432 #define WSAEADDRINUSE   (WSABASEERR+48)
433 #define WSAEADDRNOTAVAIL        (WSABASEERR+49)
434 #define WSAENETDOWN     (WSABASEERR+50)
435 #define WSAENETUNREACH  (WSABASEERR+51)
436 #define WSAENETRESET    (WSABASEERR+52)
437 #define WSAECONNABORTED (WSABASEERR+53)
438 #define WSAECONNRESET   (WSABASEERR+54)
439 #define WSAENOBUFS      (WSABASEERR+55)
440 #define WSAEISCONN      (WSABASEERR+56)
441 #define WSAENOTCONN     (WSABASEERR+57)
442 #define WSAESHUTDOWN    (WSABASEERR+58)
443 #define WSAETOOMANYREFS (WSABASEERR+59)
444 #define WSAETIMEDOUT    (WSABASEERR+60)
445 #define WSAECONNREFUSED (WSABASEERR+61)
446 #define WSAELOOP        (WSABASEERR+62)
447 #define WSAENAMETOOLONG (WSABASEERR+63)
448 #define WSAEHOSTDOWN    (WSABASEERR+64)
449 #define WSAEHOSTUNREACH (WSABASEERR+65)
450 #define WSAENOTEMPTY    (WSABASEERR+66)
451 #define WSAEPROCLIM     (WSABASEERR+67)
452 #define WSAEUSERS       (WSABASEERR+68)
453 #define WSAEDQUOT       (WSABASEERR+69)
454 #define WSAESTALE       (WSABASEERR+70)
455 #define WSAEREMOTE      (WSABASEERR+71)
456 #define WSAEDISCON      (WSABASEERR+101)
457 #define WSASYSNOTREADY  (WSABASEERR+91)
458 #define WSAVERNOTSUPPORTED      (WSABASEERR+92)
459 #define WSANOTINITIALISED       (WSABASEERR+93)
460 #define WSAHOST_NOT_FOUND       (WSABASEERR+1001)
461 #define WSATRY_AGAIN    (WSABASEERR+1002)
462 #define WSANO_RECOVERY  (WSABASEERR+1003)
463 #define WSANO_DATA      (WSABASEERR+1004)
464 #endif /* !WSABASEERR */
465
466 #define WSANO_ADDRESS   WSANO_DATA
467
468 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
469 #define h_errno WSAGetLastError()
470 #define HOST_NOT_FOUND  WSAHOST_NOT_FOUND
471 #define TRY_AGAIN       WSATRY_AGAIN
472 #define NO_RECOVERY     WSANO_RECOVERY
473 #define NO_DATA WSANO_DATA
474 #define NO_ADDRESS      WSANO_ADDRESS
475 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
476
477 SOCKET PASCAL accept(SOCKET,struct sockaddr*,int*);
478 int PASCAL bind(SOCKET,const struct sockaddr*,int);
479 int PASCAL closesocket(SOCKET);
480 int PASCAL connect(SOCKET,const struct sockaddr*,int);
481 int PASCAL ioctlsocket(SOCKET,long,u_long *);
482 int PASCAL getpeername(SOCKET,struct sockaddr*,int*);
483 int PASCAL getsockname(SOCKET,struct sockaddr*,int*);
484 int PASCAL getsockopt(SOCKET,int,int,char*,int*);
485 unsigned long PASCAL inet_addr(const char*);
486 DECLARE_STDCALL_P(char *) inet_ntoa(struct in_addr);
487 int PASCAL listen(SOCKET,int);
488 int PASCAL recv(SOCKET,char*,int,int);
489 int PASCAL recvfrom(SOCKET,char*,int,int,struct sockaddr*,int*);
490 int PASCAL send(SOCKET,const char*,int,int);
491 int PASCAL sendto(SOCKET,const char*,int,int,const struct sockaddr*,int);
492 int PASCAL setsockopt(SOCKET,int,int,const char*,int);
493 int PASCAL shutdown(SOCKET,int);
494 SOCKET PASCAL socket(int,int,int);
495 DECLARE_STDCALL_P(struct hostent *) gethostbyaddr(const char*,int,int);
496 DECLARE_STDCALL_P(struct hostent *) gethostbyname(const char*);
497 DECLARE_STDCALL_P(struct servent *) getservbyport(int,const char*);
498 DECLARE_STDCALL_P(struct servent *) getservbyname(const char*,const char*);
499 DECLARE_STDCALL_P(struct protoent *) getprotobynumber(int);
500 DECLARE_STDCALL_P(struct protoent *) getprotobyname(const char*);
501 int PASCAL WSAStartup(WORD,LPWSADATA);
502 int PASCAL WSACleanup(void);
503 void PASCAL WSASetLastError(int);
504 int PASCAL WSAGetLastError(void);
505 BOOL PASCAL WSAIsBlocking(void);
506 int PASCAL WSAUnhookBlockingHook(void);
507 FARPROC PASCAL WSASetBlockingHook(FARPROC);
508 int PASCAL WSACancelBlockingCall(void);
509 HANDLE PASCAL WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int);
510 HANDLE PASCAL WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int);
511 HANDLE PASCAL WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int);
512 HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int);
513 HANDLE PASCAL WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int);
514 HANDLE PASCAL WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int);
515 int PASCAL WSACancelAsyncRequest(HANDLE);
516 int PASCAL WSAAsyncSelect(SOCKET,HWND,u_int,long);
517
518 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
519 u_long PASCAL htonl(u_long);
520 u_long PASCAL ntohl(u_long);
521 u_short PASCAL htons(u_short);
522 u_short PASCAL ntohs(u_short);
523 int PASCAL select(int nfds,fd_set*,fd_set*,fd_set*,const struct timeval*);
524 int PASCAL gethostname(char*,int);
525 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
526
527 #define WSAMAKEASYNCREPLY(b,e)  MAKELONG(b,e)
528 #define WSAMAKESELECTREPLY(e,error)     MAKELONG(e,error)
529 #define WSAGETASYNCBUFLEN(l)    LOWORD(l)
530 #define WSAGETASYNCERROR(l)     HIWORD(l)
531 #define WSAGETSELECTEVENT(l)    LOWORD(l)
532 #define WSAGETSELECTERROR(l)    HIWORD(l)
533
534 typedef struct sockaddr SOCKADDR;
535 typedef struct sockaddr *PSOCKADDR;
536 typedef struct sockaddr *LPSOCKADDR;
537 typedef struct sockaddr_in SOCKADDR_IN;
538 typedef struct sockaddr_in *PSOCKADDR_IN;
539 typedef struct sockaddr_in *LPSOCKADDR_IN;
540 typedef struct linger LINGER;
541 typedef struct linger *PLINGER;
542 typedef struct linger *LPLINGER;
543 typedef struct in_addr IN_ADDR;
544 typedef struct in_addr *PIN_ADDR;
545 typedef struct in_addr *LPIN_ADDR;
546 typedef struct fd_set FD_SET;
547 typedef struct fd_set *PFD_SET;
548 typedef struct fd_set *LPFD_SET;
549 typedef struct hostent HOSTENT;
550 typedef struct hostent *PHOSTENT;
551 typedef struct hostent *LPHOSTENT;
552 typedef struct servent SERVENT;
553 typedef struct servent *PSERVENT;
554 typedef struct servent *LPSERVENT;
555 typedef struct protoent PROTOENT;
556 typedef struct protoent *PPROTOENT;
557 typedef struct protoent *LPPROTOENT;
558 typedef struct timeval TIMEVAL;
559 typedef struct timeval *PTIMEVAL;
560 typedef struct timeval *LPTIMEVAL;
561
562 #ifdef __cplusplus
563 }
564 #endif
565 /*
566  * Recent MSDN docs indicate that the MS-specific extensions exported from
567  * mswsock.dll (AcceptEx, TransmitFile. WSARecEx and GetAcceptExSockaddrs) are
568  * declared in mswsock.h. These extensions are not supported on W9x or WinCE.
569  * However, code using WinSock 1.1 API may expect the declarations and
570  * associated defines to be in this header. Thus we include mswsock.h here.
571  *
572  * When linking against the WinSock 1.1 lib, wsock32.dll, the mswsock functions
573  * are automatically routed to mswsock.dll (on platforms with support).
574  * The WinSock 2 lib, ws2_32.dll, does not contain any references to
575  * the mswsock extensions. 
576  */
577
578 #include <mswsock.h>
579
580 #endif