[PSDK]
[reactos.git] / include / psdk / winsock.h
1 /*
2 Definitions for winsock 1.1
3
4 Portions Copyright (c) 1980, 1983, 1988, 1993
5 The Regents of the University of California. All rights reserved.
6
7 Portions Copyright (c) 1993 by Digital Equipment Corporation.
8 */
9
10 #pragma once
11
12 #define _WINSOCKAPI_
13
14 #ifndef _INC_WINDOWS
15 #include <windows.h>
16 #endif
17
18 #ifndef _M_AMD64
19 #if !defined(__ROS_LONG64__)
20 #ifdef __WINESRC__
21 #define __ROS_LONG64__
22 #endif
23 #endif
24 #endif
25
26 #define _GNU_H_WINDOWS32_SOCKETS
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #if !defined ( _BSDTYPES_DEFINED )
33
34 /* also defined in gmon.h and in cygwin's sys/types */
35 typedef unsigned char u_char;
36 typedef unsigned short u_short;
37 typedef unsigned int u_int;
38
39 #ifndef __ROS_LONG64__
40 typedef unsigned long u_long;
41 #else
42 typedef unsigned int u_long;
43 #endif
44
45 #define _BSDTYPES_DEFINED
46
47 #endif /* !defined ( _BSDTYPES_DEFINED ) */
48
49 typedef UINT_PTR SOCKET;
50
51 #ifndef FD_SETSIZE
52 #define FD_SETSIZE 64
53 #endif
54
55 /* shutdown() how types */
56 #define SD_RECEIVE 0x00
57 #define SD_SEND 0x01
58 #define SD_BOTH 0x02
59
60 #ifndef _SYS_TYPES_FD_SET
61
62 /* fd_set may have be defined by the newlib <sys/types.h>
63 * if __USE_W32_SOCKETS not defined.
64 */
65 #ifdef fd_set
66 #undef fd_set
67 #endif
68 typedef struct fd_set {
69 u_int fd_count;
70 SOCKET fd_array[FD_SETSIZE];
71 } fd_set;
72
73 extern int PASCAL __WSAFDIsSet(SOCKET,fd_set FAR*);
74
75 #ifndef FD_CLR
76 #define FD_CLR(fd,set) do { u_int __i;\
77 for (__i = 0; __i < ((fd_set FAR*)(set))->fd_count ; __i++) {\
78 if (((fd_set FAR*)(set))->fd_array[__i] == (fd)) {\
79 while (__i < ((fd_set FAR*)(set))->fd_count-1) {\
80 ((fd_set FAR*)(set))->fd_array[__i] = ((fd_set FAR*)(set))->fd_array[__i+1];\
81 __i++;\
82 }\
83 ((fd_set FAR*)(set))->fd_count--;\
84 break;\
85 }\
86 }\
87 } while (0)
88 #endif /* FD_CLR */
89
90 #ifndef FD_SET
91 #define FD_SET(fd, set) do { \
92 if (((fd_set FAR*)(set))->fd_count < FD_SETSIZE) \
93 ((fd_set FAR*)(set))->fd_array[((fd_set FAR*)(set))->fd_count++]=(fd);\
94 }while (0)
95 #endif
96
97 #ifndef FD_ZERO
98 #define FD_ZERO(set) (((fd_set FAR*)(set))->fd_count=0)
99 #endif
100
101 #ifndef FD_ISSET
102 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR*)(set))
103 #endif
104
105
106
107 #elif !defined(USE_SYS_TYPES_FD_SET)
108 #warning "fd_set and associated macros have been defined in sys/types. \
109 This can cause runtime problems with W32 sockets"
110 #endif /* ndef _SYS_TYPES_FD_SET */
111
112 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
113
114 #ifndef _TIMEVAL_DEFINED /* also in sys/time.h */
115 #define _TIMEVAL_DEFINED
116
117 struct timeval {
118 LONG tv_sec;
119 LONG tv_usec;
120 };
121
122 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
123
124 #define timercmp(tvp, uvp, cmp) \
125 (((tvp)->tv_sec != (uvp)->tv_sec) ? \
126 ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
127 ((tvp)->tv_usec cmp (uvp)->tv_usec))
128
129 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
130
131 #endif /* _TIMEVAL_DEFINED */
132
133 #define h_addr h_addr_list[0]
134
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 };
142
143 struct linger {
144 u_short l_onoff;
145 u_short l_linger;
146 };
147
148 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
149 #define _IOR(x,y,t) (IOC_OUT|(((LONG)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
150 #define _IOW(x,y,t) (IOC_IN|(((LONG)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
151 #define FIONBIO _IOW('f', 126, u_long)
152
153 struct netent {
154 char * n_name;
155 char **n_aliases;
156 short n_addrtype;
157 u_long n_net;
158 };
159
160 struct servent {
161 char *s_name;
162 char **s_aliases;
163 #ifdef _WIN64
164 char *s_proto;
165 short s_port;
166 #else
167 short s_port;
168 char *s_proto;
169 };
170
171 struct protoent {
172 char *p_name;
173 char **p_aliases;
174 short p_proto;
175 };
176
177 #define IP_OPTIONS 1
178
179 #define SO_DEBUG 1
180 #define SO_ACCEPTCONN 2
181 #define SO_REUSEADDR 4
182 #define SO_KEEPALIVE 8
183 #define SO_DONTROUTE 16
184 #define SO_BROADCAST 32
185 #define SO_USELOOPBACK 64
186 #define SO_LINGER 128
187 #define SO_OOBINLINE 256
188 #define SO_DONTLINGER (u_int)(~SO_LINGER)
189 #define SO_SNDBUF 0x1001
190 #define SO_RCVBUF 0x1002
191 #define SO_SNDLOWAT 0x1003
192 #define SO_RCVLOWAT 0x1004
193 #define SO_SNDTIMEO 0x1005
194 #define SO_RCVTIMEO 0x1006
195 #define SO_ERROR 0x1007
196 #define SO_TYPE 0x1008
197
198 #define SO_CONNDATA 0x7000
199 #define SO_CONNOPT 0x7001
200 #define SO_DISCDATA 0x7002
201 #define SO_DISCOPT 0x7003
202 #define SO_CONNDATALEN 0x7004
203 #define SO_CONNOPTLEN 0x7005
204 #define SO_DISCDATALEN 0x7006
205 #define SO_DISCOPTLEN 0x7007
206 #define SO_OPENTYPE 0x7008
207 #define SO_MAXDG 0x7009
208 #define SO_MAXPATHDG 0x700A
209 #define SO_UPDATE_ACCEPT_CONTEXT 0x700B
210 #define SO_CONNECT_TIME 0x700C
211
212 #define SO_SYNCHRONOUS_ALERT 0x10
213 #define SO_SYNCHRONOUS_NONALERT 0x20
214
215 #define AF_MAX 24
216
217 struct sockaddr {
218 u_short sa_family;
219 char sa_data[14];
220 };
221
222 #define MSG_OOB 1
223 #define MSG_PEEK 2
224 #define MSG_DONTROUTE 4
225
226 #define h_errno WSAGetLastError()
227 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
228 #define TRY_AGAIN WSATRY_AGAIN
229 #define NO_RECOVERY WSANO_RECOVERY
230 #define NO_DATA WSANO_DATA
231 #define NO_ADDRES WSANO_ADDRESS
232
233 u_long PASCAL htonl(u_long);
234 u_long PASCAL ntohl(u_long);
235 u_short PASCAL htons(u_short);
236 u_short PASCAL ntohs(u_short);
237 int PASCAL select(int nfds,fd_set*,fd_set*,fd_set*,const struct timeval*);
238 int PASCAL gethostname(char*,int);
239
240 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
241
242 #define IOCPARM_MASK 0x7f
243 #define IOC_VOID 0x20000000
244 #define IOC_OUT 0x40000000
245 #define IOC_IN 0x80000000
246 #define IOC_INOUT (IOC_IN|IOC_OUT)
247
248 #define FIONREAD _IOR('f', 127, u_long)
249 #define FIOASYNC _IOW('f', 125, u_long)
250 #define SIOCSHIWAT _IOW('s', 0, u_long)
251 #define SIOCGHIWAT _IOR('s', 1, u_long)
252 #define SIOCSLOWAT _IOW('s', 2, u_long)
253 #define SIOCGLOWAT _IOR('s', 3, u_long)
254 #define SIOCATMARK _IOR('s', 7, u_long)
255
256 #define IPPROTO_IP 0
257 #define IPPROTO_ICMP 1
258 #define IPPROTO_IGMP 2
259 #define IPPROTO_GGP 3
260 #define IPPROTO_TCP 6
261 #define IPPROTO_PUP 12
262 #define IPPROTO_UDP 17
263 #define IPPROTO_IDP 22
264 #define IPPROTO_ND 77
265 #define IPPROTO_RAW 255
266 #define IPPROTO_MAX 256
267 #define IPPORT_ECHO 7
268 #define IPPORT_DISCARD 9
269 #define IPPORT_SYSTAT 11
270 #define IPPORT_DAYTIME 13
271 #define IPPORT_NETSTAT 15
272 #define IPPORT_FTP 21
273 #define IPPORT_TELNET 23
274 #define IPPORT_SMTP 25
275 #define IPPORT_TIMESERVER 37
276 #define IPPORT_NAMESERVER 42
277 #define IPPORT_WHOIS 43
278 #define IPPORT_MTP 57
279 #define IPPORT_TFTP 69
280 #define IPPORT_RJE 77
281 #define IPPORT_FINGER 79
282 #define IPPORT_TTYLINK 87
283 #define IPPORT_SUPDUP 95
284 #define IPPORT_EXECSERVER 512
285 #define IPPORT_LOGINSERVER 513
286 #define IPPORT_CMDSERVER 514
287 #define IPPORT_EFSSERVER 520
288 #define IPPORT_BIFFUDP 512
289 #define IPPORT_WHOSERVER 513
290 #define IPPORT_ROUTESERVER 520
291 #define IPPORT_RESERVED 1024
292 #define IMPLINK_IP 155
293 #define IMPLINK_LOWEXPER 156
294 #define IMPLINK_HIGHEXPER 158
295
296 #include <inaddr.h>
297
298 #define IN_CLASSA(i) ((LONG)(i)&0x80000000)
299 #define IN_CLASSA_NET 0xff000000
300 #define IN_CLASSA_NSHIFT 24
301 #define IN_CLASSA_HOST 0x00ffffff
302 #define IN_CLASSA_MAX 128
303 #define IN_CLASSB(i) (((LONG)(i)&0xc0000000)==0x80000000)
304 #define IN_CLASSB_NET 0xffff0000
305 #define IN_CLASSB_NSHIFT 16
306 #define IN_CLASSB_HOST 0x0000ffff
307 #define IN_CLASSB_MAX 65536
308 #define IN_CLASSC(i) (((LONG)(i)&0xe0000000)==0xc0000000)
309 #define IN_CLASSC_NET 0xffffff00
310 #define IN_CLASSC_NSHIFT 8
311 #define IN_CLASSC_HOST 0xff
312 #define INADDR_ANY (u_long)0
313 #define INADDR_LOOPBACK 0x7f000001
314 #define INADDR_BROADCAST (u_long)0xffffffff
315 #define INADDR_NONE 0xffffffff
316
317 struct sockaddr_in {
318 short sin_family;
319 u_short sin_port;
320 struct in_addr sin_addr;
321 char sin_zero[8];
322 };
323
324 #define WSADESCRIPTION_LEN 256
325 #define WSASYS_STATUS_LEN 128
326
327 typedef struct WSAData {
328 WORD wVersion;
329 WORD wHighVersion;
330 #ifdef _WIN64
331 unsigned short iMaxSockets;
332 unsigned short iMaxUdpDg;
333 char *lpVendorInfo;
334 char szDescription[WSADESCRIPTION_LEN+1];
335 char szSystemStatus[WSASYS_STATUS_LEN+1];
336 #else
337 char szDescription[WSADESCRIPTION_LEN+1];
338 char szSystemStatus[WSASYS_STATUS_LEN+1];
339 unsigned short iMaxSockets;
340 unsigned short iMaxUdpDg;
341 char *lpVendorInfo;
342 } WSADATA, FAR *LPWSADATA;
343
344 /*
345 * Note that the next 5 IP defines are specific to WinSock 1.1 (wsock32.dll).
346 * They will cause errors or unexpected results if used with the
347 * (gs)etsockopts exported from the WinSock 2 lib, ws2_32.dll. Refer ws2tcpip.h.
348 */
349 #define IP_MULTICAST_IF 2
350 #define IP_MULTICAST_TTL 3
351 #define IP_MULTICAST_LOOP 4
352 #define IP_ADD_MEMBERSHIP 5
353 #define IP_DROP_MEMBERSHIP 6
354 #define IP_TTL 7
355 #define IP_TOS 8
356 #define IP_DONTFRAGMENT 9
357
358 #define IP_DEFAULT_MULTICAST_TTL 1
359 #define IP_DEFAULT_MULTICAST_LOOP 1
360 #define IP_MAX_MEMBERSHIPS 20
361
362 struct ip_mreq {
363 struct in_addr imr_multiaddr;
364 struct in_addr imr_interface;
365 };
366
367 #define INVALID_SOCKET (SOCKET)(~0)
368 #define SOCKET_ERROR (-1)
369
370 #define SOCK_STREAM 1
371 #define SOCK_DGRAM 2
372 #define SOCK_RAW 3
373 #define SOCK_RDM 4
374 #define SOCK_SEQPACKET 5
375
376 #define TCP_NODELAY 0x0001
377 #define TCP_BSDURGENT 0x7000
378
379 #define AF_UNSPEC 0
380 #define AF_UNIX 1
381 #define AF_INET 2
382 #define AF_IMPLINK 3
383 #define AF_PUP 4
384 #define AF_CHAOS 5
385 #define AF_IPX 6
386 #define AF_NS 6
387 #define AF_ISO 7
388 #define AF_OSI AF_ISO
389 #define AF_ECMA 8
390 #define AF_DATAKIT 9
391 #define AF_CCITT 10
392 #define AF_SNA 11
393 #define AF_DECnet 12
394 #define AF_DLI 13
395 #define AF_LAT 14
396 #define AF_HYLINK 15
397 #define AF_APPLETALK 16
398 #define AF_NETBIOS 17
399 #define AF_VOICEVIEW 18
400 #define AF_FIREFOX 19
401 #define AF_UNKNOWN1 20
402 #define AF_BAN 21
403 #define AF_ATM 22
404 #define AF_INET6 23
405
406 struct sockproto {
407 u_short sp_family;
408 u_short sp_protocol;
409 };
410
411 #define PF_UNSPEC AF_UNSPEC
412 #define PF_UNIX AF_UNIX
413 #define PF_INET AF_INET
414 #define PF_IMPLINK AF_IMPLINK
415 #define PF_PUP AF_PUP
416 #define PF_CHAOS AF_CHAOS
417 #define PF_NS AF_NS
418 #define PF_IPX AF_IPX
419 #define PF_ISO AF_ISO
420 #define PF_OSI AF_OSI
421 #define PF_ECMA AF_ECMA
422 #define PF_DATAKIT AF_DATAKIT
423 #define PF_CCITT AF_CCITT
424 #define PF_SNA AF_SNA
425 #define PF_DECnet AF_DECnet
426 #define PF_DLI AF_DLI
427 #define PF_LAT AF_LAT
428 #define PF_HYLINK AF_HYLINK
429 #define PF_APPLETALK AF_APPLETALK
430 #define PF_VOICEVIEW AF_VOICEVIEW
431 #define PF_FIREFOX AF_FIREFOX
432 #define PF_UNKNOWN1 AF_UNKNOWN1
433 #define PF_BAN AF_BAN
434 #define PF_ATM AF_ATM
435 #define PF_INET6 AF_INET6
436 #define PF_MAX AF_MAX
437
438 #define SOL_SOCKET 0xffff
439 #define SOMAXCONN 5
440
441 #define MSG_MAXIOVLEN 16
442 #define MSG_PARTIAL 0x8000
443 #define MAXGETHOSTSTRUCT 1024
444
445 #define FD_READ 1
446 #define FD_WRITE 2
447 #define FD_OOB 4
448 #define FD_ACCEPT 8
449 #define FD_CONNECT 16
450 #define FD_CLOSE 32
451
452 #ifndef WSABASEERR
453
454 #define WSABASEERR 10000
455 #define WSAEINTR (WSABASEERR+4)
456 #define WSAEBADF (WSABASEERR+9)
457 #define WSAEACCES (WSABASEERR+13)
458 #define WSAEFAULT (WSABASEERR+14)
459 #define WSAEINVAL (WSABASEERR+22)
460 #define WSAEMFILE (WSABASEERR+24)
461 #define WSAEWOULDBLOCK (WSABASEERR+35)
462 #define WSAEINPROGRESS (WSABASEERR+36)
463 #define WSAEALREADY (WSABASEERR+37)
464 #define WSAENOTSOCK (WSABASEERR+38)
465 #define WSAEDESTADDRREQ (WSABASEERR+39)
466 #define WSAEMSGSIZE (WSABASEERR+40)
467 #define WSAEPROTOTYPE (WSABASEERR+41)
468 #define WSAENOPROTOOPT (WSABASEERR+42)
469 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
470 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
471 #define WSAEOPNOTSUPP (WSABASEERR+45)
472 #define WSAEPFNOSUPPORT (WSABASEERR+46)
473 #define WSAEAFNOSUPPORT (WSABASEERR+47)
474 #define WSAEADDRINUSE (WSABASEERR+48)
475 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
476 #define WSAENETDOWN (WSABASEERR+50)
477 #define WSAENETUNREACH (WSABASEERR+51)
478 #define WSAENETRESET (WSABASEERR+52)
479 #define WSAECONNABORTED (WSABASEERR+53)
480 #define WSAECONNRESET (WSABASEERR+54)
481 #define WSAENOBUFS (WSABASEERR+55)
482 #define WSAEISCONN (WSABASEERR+56)
483 #define WSAENOTCONN (WSABASEERR+57)
484 #define WSAESHUTDOWN (WSABASEERR+58)
485 #define WSAETOOMANYREFS (WSABASEERR+59)
486 #define WSAETIMEDOUT (WSABASEERR+60)
487 #define WSAECONNREFUSED (WSABASEERR+61)
488 #define WSAELOOP (WSABASEERR+62)
489 #define WSAENAMETOOLONG (WSABASEERR+63)
490 #define WSAEHOSTDOWN (WSABASEERR+64)
491 #define WSAEHOSTUNREACH (WSABASEERR+65)
492 #define WSAENOTEMPTY (WSABASEERR+66)
493 #define WSAEPROCLIM (WSABASEERR+67)
494 #define WSAEUSERS (WSABASEERR+68)
495 #define WSAEDQUOT (WSABASEERR+69)
496 #define WSAESTALE (WSABASEERR+70)
497 #define WSAEREMOTE (WSABASEERR+71)
498 #define WSASYSNOTREADY (WSABASEERR+91)
499 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
500 #define WSANOTINITIALISED (WSABASEERR+93)
501 #define WSAEDISCON (WSABASEERR+101)
502 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
503 #define WSATRY_AGAIN (WSABASEERR+1002)
504 #define WSANO_RECOVERY (WSABASEERR+1003)
505 #define WSANO_DATA (WSABASEERR+1004)
506 #define WSA_SECURE_HOST_NOT_FOUND (WSABASEERR+1032)
507 #define WSA_IPSEC_NAME_POLICY_ERROR (WSABASEERR+1033)
508
509 #endif /* !WSABASEERR */
510
511 #define WSANO_ADDRESS WSANO_DATA
512
513 SOCKET
514 PASCAL FAR
515 accept(
516 IN SOCKET s,
517 OUT struct sockaddr FAR *addr OPTIONAL,
518 IN OUT int FAR *addrlen OPTIONAL);
519
520 int
521 PASCAL FAR
522 bind(
523 IN SOCKET s,
524 IN const struct sockaddr FAR *addr,
525 IN int namelen);
526
527 int
528 PASCAL FAR
529 closesocket(
530 IN SOCKET s);
531
532 int
533 PASCAL FAR
534 connect(
535 IN SOCKET s,
536 IN const struct sockaddr FAR *name,
537 IN int namelen);
538
539 int
540 PASCAL FAR
541 ioctlsocket(
542 IN SOCKET s,
543 IN long cmd,
544 IN OUT u_long FAR *argp);
545
546 int
547 PASCAL FAR
548 getpeername(
549 IN SOCKET s,
550 OUT struct sockaddr FAR *name,
551 IN OUT int FAR *namelen);
552
553 int
554 PASCAL FAR
555 getsockname(
556 IN SOCKET s,
557 OUT struct sockaddr FAR *name,
558 IN OUT int FAR *namelen);
559
560 int
561 PASCAL FAR
562 getsockopt(
563 IN SOCKET s,
564 IN int level,
565 IN int optname,
566 OUT char FAR *optval,
567 IN OUT int FAR *optlen);
568
569 u_long
570 PASCAL FAR
571 htonl(
572 IN u_long hostlong);
573
574 u_short
575 PASCAL FAR
576 htons(
577 IN u_short hostshort);
578
579 unsigned long
580 PASCAL FAR
581 inet_addr(
582 IN const char FAR *cp);
583
584 char FAR
585 *PASCAL FAR
586 inet_ntoa(
587 IN struct in_addr in);
588
589 int
590 PASCAL FAR
591 listen(
592 IN SOCKET s,
593 IN int backlog);
594
595 u_long
596 PASCAL FAR
597 ntohl(
598 IN u_long netlong);
599
600 u_short
601 PASCAL FAR
602 ntohs(
603 IN u_short netshort);
604
605 int
606 PASCAL FAR
607 recv(
608 IN SOCKET s,
609 OUT char FAR *buf,
610 IN int len,
611 IN int flags);
612
613 int
614 PASCAL FAR
615 recvfrom(
616 IN SOCKET s,
617 OUT char FAR *buf,
618 IN int len,
619 IN int flags,
620 OUT struct sockaddr FAR *from OPTIONAL,
621 IN OUY int FAR * fromlen OPTIONAL);
622
623 int
624 PASCAL FAR
625 select(
626 IN int nfds,
627 IN OUT fd_set FAR *readfds OPTIONAL,
628 IN OUT fd_set FAR *writefds OPTIONAL,
629 IN OUT fd_set FAR *exceptfds OPTIONAL,
630 IN const struct timeval FAR *timeout OPTIONAL);
631
632 int
633 PASCAL FAR
634 send(
635 IN SOCKET s,
636 IN const char FAR *buf,
637 IN int len,
638 IN int flags);
639
640 int
641 PASCAL FAR
642 sendto(
643 IN SOCKET s,
644 IN const char FAR *buf,
645 IN int len,
646 IN int flags,
647 IN const struct sockaddr FAR *to OPTIONAL,
648 IN int tolen);
649
650 int
651 PASCAL FAR
652 setsockopt(
653 IN SOCKET s,
654 IN int level,
655 IN int optname,
656 IN const char FAR *optval OPTIONAL,
657 IN int optlen);
658
659 int
660 PASCAL FAR
661 shutdown(
662 IN SOCKET s,
663 IN int how);
664
665 SOCKET
666 PASCAL FAR
667 socket(
668 IN int af,
669 IN int type,
670 IN int protocol);
671
672 struct hostent FAR
673 *PASCAL FAR
674 gethostbyaddr(
675 IN const char FAR *addr,
676 IN int len,
677 IN int type);
678
679 struct hostent FAR
680 *PASCAL FAR
681 gethostbyname(
682 IN const char FAR *name);
683
684 int
685 PASCAL FAR
686 gethostname(
687 OUT char FAR *name,
688 IN int namelen);
689
690 struct servent FAR
691 *PASCAL FAR
692 getservbyport(
693 IN int port,
694 IN const char FAR *proto);
695
696 struct servent FAR
697 *PASCAL FAR
698 getservbyname(
699 IN const char FAR *name,
700 IN const char FAR *proto);
701
702 struct protoent FAR
703 *PASCAL FAR
704 getprotobynumber(
705 IN int number);
706
707 struct protoent FAR
708 *PASCAL FAR
709 getprotobyname(
710 IN const char FAR *name);
711
712 int
713 PASCAL FAR
714 WSAStartup(
715 IN WORD wVersionRequired,
716 OUT LPWSADATA lpWSAData);
717
718 int
719 PASCAL FAR
720 WSACleanup(void);
721
722 void
723 PASCAL FAR
724 WSASetLastError(
725 IN int iError);
726
727 int
728 PASCAL FAR
729 WSAGetLastError(void);
730
731 BOOL
732 PASCAL FAR
733 WSAIsBlocking(void);
734
735 int
736 PASCAL FAR
737 WSAUnhookBlockingHook(void);
738
739 FARPROC
740 PASCAL FAR
741 WSASetBlockingHook(
742 IN FARPROC lpBlockFunc);
743
744 int
745 PASCAL FAR
746 WSACancelBlockingCall(void);
747
748 HANDLE
749 PASCAL FAR
750 WSAAsyncGetServByName(
751 IN HWND hWnd,
752 IN u_int wMsg,
753 IN const char FAR *name,
754 IN const char FAR *proto,
755 OUT char FAR *buf,
756 IN int buflen);
757
758 HANDLE
759 PASCAL FAR
760 WSAAsyncGetServByPort(
761 IN HWND hWnd,
762 IN u_int wMsg,
763 IN int port,
764 IN const char FAR *proto,
765 OUT char FAR *buf,
766 IN int buflen);
767
768 HANDLE
769 PASCAL FAR
770 WSAAsyncGetProtoByName(
771 IN HWND hWnd,
772 IN u_int wMsg,
773 IN const char FAR *name,
774 OUT char FAR *buf,
775 IN int buflen);
776
777 HANDLE
778 PASCAL FAR
779 WSAAsyncGetProtoByNumber(
780 IN HWND hWnd,
781 IN u_int wMsg,
782 IN int number,
783 OUT char FAR *buf,
784 IN int buflen);
785
786 HANDLE
787 PASCAL FAR
788 WSAAsyncGetHostByName(
789 IN HWND hWnd,
790 IN u_int wMsg,
791 IN const char FAR *name,
792 OUT char FAR *buf,
793 IN int buflen);
794
795 HANDLE
796 PASCAL FAR
797 WSAAsyncGetHostByAddr(
798 IN HWND hWnd,
799 IN u_int wMsg,
800 IN const char FAR *addr,
801 IN int len,
802 IN int type,
803 OUT char FAR *buf,
804 IN int buflen);
805
806 int
807 PASCAL FAR
808 WSACancelAsyncRequest(
809 IN HANDLE hAsyncTaskHandle);
810
811 int
812 PASCAL FAR
813 WSAAsyncSelect(
814 IN SOCKET s,
815 IN HWND hWnd,
816 IN u_int wMsg,
817 IN long lEvent);
818
819 int
820 PASCAL FAR
821 WSARecvEx(
822 IN SOCKET s,
823 OUT char FAR *buf,
824 IN int len,
825 IN OUT int FAR *flags);
826
827 typedef struct _TRANSMIT_FILE_BUFFERS {
828 PVOID Head;
829 DWORD HeadLength;
830 PVOID Tail;
831 DWORD TailLength;
832 } TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
833
834 #define TF_DISCONNECT 0x01
835 #define TF_REUSE_SOCKET 0x02
836 #define TF_WRITE_BEHIND 0x04
837
838 BOOL
839 PASCAL FAR
840 TransmitFile(
841 IN SOCKET hSocket,
842 IN HANDLE hFile,
843 IN DWORD nNumberOfBytesToWrite,
844 IN DWORD nNumberOfBytesPerSend,
845 IN OUT LPOVERLAPPED lpOverlapped OPTIONAL,
846 IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers OPTIONAL,
847 IN DWORD dwReserved);
848
849 BOOL
850 PASCAL FAR
851 AcceptEx(
852 IN SOCKET sListenSocket,
853 IN SOCKET sAcceptSocket,
854 OUT PVOID lpOutputBuffer,
855 IN DWORD dwReceiveDataLength,
856 IN DWORD dwLocalAddressLength,
857 IN DWORD dwRemoteAddressLength,
858 OUT LPDWORD lpdwBytesReceived,
859 IN OUT LPOVERLAPPED lpOverlapped);
860
861 VOID
862 PASCAL FAR
863 GetAcceptExSockaddrs(
864 IN PVOID lpOutputBuffer,
865 IN DWORD dwReceiveDataLength,
866 IN DWORD dwLocalAddressLength,
867 IN DWORD dwRemoteAddressLength,
868 OUT struct sockaddr **LocalSockaddr,
869 OUT LPINT LocalSockaddrLength,
870 OUT struct sockaddr **RemoteSockaddr,
871 OUT LPINT RemoteSockaddrLength);
872
873 #define WSAMAKEASYNCREPLY(b,e) MAKELONG(b,e)
874 #define WSAMAKESELECTREPLY(e,error) MAKELONG(e,error)
875 #define WSAGETASYNCBUFLEN(l) LOWORD(l)
876 #define WSAGETASYNCERROR(l) HIWORD(l)
877 #define WSAGETSELECTEVENT(l) LOWORD(l)
878 #define WSAGETSELECTERROR(l) HIWORD(l)
879
880 typedef struct sockaddr SOCKADDR;
881 typedef struct sockaddr *PSOCKADDR;
882 typedef struct sockaddr *LPSOCKADDR;
883 typedef struct sockaddr_in SOCKADDR_IN;
884 typedef struct sockaddr_in *PSOCKADDR_IN;
885 typedef struct sockaddr_in *LPSOCKADDR_IN;
886 typedef struct linger LINGER;
887 typedef struct linger *PLINGER;
888 typedef struct linger *LPLINGER;
889 typedef struct in_addr IN_ADDR;
890 typedef struct in_addr *PIN_ADDR;
891 typedef struct in_addr *LPIN_ADDR;
892 typedef struct fd_set FD_SET;
893 typedef struct fd_set *PFD_SET;
894 typedef struct fd_set *LPFD_SET;
895 typedef struct hostent HOSTENT;
896 typedef struct hostent *PHOSTENT;
897 typedef struct hostent *LPHOSTENT;
898 typedef struct servent SERVENT;
899 typedef struct servent *PSERVENT;
900 typedef struct servent *LPSERVENT;
901 typedef struct protoent PROTOENT;
902 typedef struct protoent *PPROTOENT;
903 typedef struct protoent *LPPROTOENT;
904 typedef struct timeval TIMEVAL;
905 typedef struct timeval *PTIMEVAL;
906 typedef struct timeval *LPTIMEVAL;
907
908 #if(_WIN32_WINNT >= 0x0501)
909
910 #ifdef IPV6STRICT
911 #error WINSOCK2 required.
912 #endif
913
914 #endif /* (_WIN32_WINNT >= 0x0501) */
915
916 #ifdef __cplusplus
917 }
918 #endif