OSDN Git Service

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