Ignore generated files.
[wine/multimedia.git] / include / winsock.h
blob38b88a5784e408f450284d4cf9b240a519664996
1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
4 * specification.
5 */
7 #ifndef _WINSOCKAPI_
8 #define _WINSOCKAPI_
10 #include <netinet/in.h>
11 #include <arpa/inet.h>
12 #include <sys/types.h>
13 #include <sys/time.h>
14 #include <fcntl.h>
15 #include <netdb.h>
16 #include <sys/socket.h>
18 #ifdef HAVE_IPX_GNU
19 # include <netipx/ipx.h>
20 # define HAVE_IPX
21 #endif
23 #ifdef HAVE_IPX_LINUX
24 # include <asm/types.h>
25 # include <linux/ipx.h>
26 # define HAVE_IPX
27 #endif
29 #include "wintypes.h"
30 #include "task.h"
32 #pragma pack(1)
34 /* Win16 socket-related types */
36 typedef UINT16 SOCKET16;
37 typedef UINT SOCKET;
39 typedef struct ws_hostent
41 SEGPTR h_name; /* official name of host */
42 SEGPTR h_aliases; /* alias list */
43 INT16 h_addrtype; /* host address type */
44 INT16 h_length; /* length of address */
45 SEGPTR h_addr_list; /* list of addresses from name server */
46 } _ws_hostent;
48 typedef struct ws_protoent
50 SEGPTR p_name; /* official protocol name */
51 SEGPTR p_aliases; /* alias list */
52 INT16 p_proto; /* protocol # */
53 } _ws_protoent;
55 typedef struct ws_servent
57 SEGPTR s_name; /* official service name */
58 SEGPTR s_aliases; /* alias list */
59 INT16 s_port; /* port # */
60 SEGPTR s_proto; /* protocol to use */
61 } _ws_servent;
63 typedef struct ws_netent
65 SEGPTR n_name; /* official name of net */
66 SEGPTR n_aliases; /* alias list */
67 INT16 n_addrtype; /* net address type */
68 INT n_net; /* network # */
69 } _ws_netent;
71 typedef struct sockaddr ws_sockaddr;
73 typedef struct
75 UINT16 fd_count; /* how many are SET? */
76 SOCKET16 fd_array[FD_SETSIZE]; /* an array of SOCKETs */
77 } ws_fd_set16;
79 typedef struct
81 UINT fd_count; /* how many are SET? */
82 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
83 } ws_fd_set32;
85 /* ws_fd_set operations */
87 INT16 WINAPI __WSAFDIsSet16( SOCKET16, ws_fd_set16 * );
88 INT WINAPI __WSAFDIsSet( SOCKET, ws_fd_set32 * );
90 #define __WS_FD_CLR(fd, set, cast) do { \
91 UINT16 __i; \
92 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
93 { \
94 if (((cast*)(set))->fd_array[__i] == fd) \
95 { \
96 while (__i < ((cast*)(set))->fd_count-1) \
97 { \
98 ((cast*)(set))->fd_array[__i] = \
99 ((cast*)(set))->fd_array[__i+1]; \
100 __i++; \
102 ((cast*)(set))->fd_count--; \
103 break; \
106 } while(0)
107 #define WS_FD_CLR16(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set16)
108 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set32)
110 #define __WS_FD_SET(fd, set, cast) do { \
111 if (((cast*)(set))->fd_count < FD_SETSIZE) \
112 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\
113 } while(0)
114 #define WS_FD_SET16(fd, set) __WS_FD_SET((fd),(set), ws_fd_set16)
115 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), ws_fd_set32)
117 #define WS_FD_ZERO16(set) (((ws_fd_set16*)(set))->fd_count=0)
118 #define WS_FD_ZERO(set) (((ws_fd_set32*)(set))->fd_count=0)
120 #define WS_FD_ISSET16(fd, set) __WSAFDIsSet16((SOCKET16)(fd), (ws_fd_set16*)(set))
121 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (ws_fd_set32*)(set))
124 * Internet address (old style... should be updated)
127 struct ws_in_addr
129 union {
130 struct { BYTE s_b1,s_b2,s_b3,s_b4; } S_un_b;
131 struct { UINT16 s_w1,s_w2; } S_un_w;
132 UINT S_addr;
133 } S_un;
134 #define ws_addr S_un.S_addr /* can be used for most tcp & ip code */
135 #define ws_host S_un.S_un_b.s_b2 /* host on imp */
136 #define ws_net S_un.S_un_b.s_b1 /* network */
137 #define ws_imp S_un.S_un_w.s_w2 /* imp */
138 #define ws_impno S_un.S_un_b.s_b4 /* imp # */
139 #define ws_lh S_un.S_un_b.s_b3 /* logical host */
142 struct ws_sockaddr_in
144 INT16 sin_family;
145 UINT16 sin_port;
146 struct ws_in_addr sin_addr;
147 BYTE sin_zero[8];
150 #define WSADESCRIPTION_LEN 256
151 #define WSASYS_STATUS_LEN 128
153 typedef struct WSAData {
154 WORD wVersion;
155 WORD wHighVersion;
156 char szDescription[WSADESCRIPTION_LEN+1];
157 char szSystemStatus[WSASYS_STATUS_LEN+1];
158 UINT16 iMaxSockets;
159 UINT16 iMaxUdpDg;
160 SEGPTR lpVendorInfo;
161 } WSADATA, *LPWSADATA;
163 #pragma pack(4)
165 /* ----------------------------------- no Win16 structure defs beyond this line! */
168 * This is used instead of -1, since the
169 * SOCKET type is unsigned.
171 #define INVALID_SOCKET16 (~0)
172 #define INVALID_SOCKET (~0)
173 #define SOCKET_ERROR (-1)
177 * Types
179 #define WS_SOCK_STREAM 1 /* stream socket */
180 #define WS_SOCK_DGRAM 2 /* datagram socket */
181 #define WS_SOCK_RAW 3 /* raw-protocol interface */
182 #define WS_SOCK_RDM 4 /* reliably-delivered message */
183 #define WS_SOCK_SEQPACKET 5 /* sequenced packet stream */
185 #define WS_SOL_SOCKET 0xffff
186 #define WS_IPPROTO_TCP 6
189 * Option flags per-socket.
191 #define WS_SO_DEBUG 0x0001 /* turn on debugging info recording */
192 #define WS_SO_ACCEPTCONN 0x0002 /* socket has had listen() */
193 #define WS_SO_REUSEADDR 0x0004 /* allow local address reuse */
194 #define WS_SO_KEEPALIVE 0x0008 /* keep connections alive */
195 #define WS_SO_DONTROUTE 0x0010 /* just use interface addresses */
196 #define WS_SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
197 #define WS_SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
198 #define WS_SO_LINGER 0x0080 /* linger on close if data present */
199 #define WS_SO_OOBINLINE 0x0100 /* leave received OOB data in line */
201 #define WS_SO_DONTLINGER (UINT)(~WS_SO_LINGER)
204 * Additional options.
206 #define WS_SO_SNDBUF 0x1001 /* send buffer size */
207 #define WS_SO_RCVBUF 0x1002 /* receive buffer size */
208 #define WS_SO_SNDLOWAT 0x1003 /* send low-water mark */
209 #define WS_SO_RCVLOWAT 0x1004 /* receive low-water mark */
210 #define WS_SO_SNDTIMEO 0x1005 /* send timeout */
211 #define WS_SO_RCVTIMEO 0x1006 /* receive timeout */
212 #define WS_SO_ERROR 0x1007 /* get error status and clear */
213 #define WS_SO_TYPE 0x1008 /* get socket type */
215 #define WS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
216 #define WS_IOC_VOID 0x20000000 /* no parameters */
217 #define WS_IOC_OUT 0x40000000 /* copy out parameters */
218 #define WS_IOC_IN 0x80000000 /* copy in parameters */
219 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
220 #define WS_IOR(x,y,t) (WS_IOC_OUT|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
221 #define WS_IOW(x,y,t) (WS_IOC_IN|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
223 /* IPPROTO_TCP options */
224 #define WS_TCP_NODELAY 1 /* do not apply nagle algorithm */
227 * Socket I/O flags (supported by spec 1.1)
230 #define FIONREAD WS_FIONREAD
231 #define FIONBIO WS_FIONBIO
232 #define WS_FIONREAD WS_IOR('f', 127, u_long)
233 #define WS_FIONBIO WS_IOW('f', 126, u_long)
235 #define WS_SIOCATMARK WS_IOR('s', 7, u_long)
238 * Maximum queue length specifiable by listen.
240 #ifdef SOMAXCONN
241 #undef SOMAXCONN
242 #endif
243 #define SOMAXCONN 5
245 #ifndef MSG_DONTROUTE
246 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
247 #endif
248 #define MSG_MAXIOVLEN 16
251 * Define constant based on rfc883, used by gethostbyxxxx() calls.
253 #define MAXGETHOSTSTRUCT 1024
256 * Define flags to be used with the WSAAsyncSelect() call.
258 #define FD_READ WS_FD_READ
259 #define FD_WRITE WS_FD_WRITE
260 #define FD_OOB WS_FD_OOB
261 #define FD_ACCEPT WS_FD_ACCEPT
262 #define FD_CONNECT WS_FD_CONNECT
263 #define FD_CLOSE WS_FD_CLOSE
264 #define WS_FD_READ 0x0001
265 #define WS_FD_WRITE 0x0002
266 #define WS_FD_OOB 0x0004
267 #define WS_FD_ACCEPT 0x0008
268 #define WS_FD_CONNECT 0x0010
269 #define WS_FD_CLOSE 0x0020
271 #define WS_FD_LISTENING 0x10000000 /* internal per-socket flags */
272 #define WS_FD_INACTIVE 0x20000000
273 #define WS_FD_CONNECTED 0x40000000
274 #define WS_FD_RAW 0x80000000
275 #define WS_FD_INTERNAL 0xFFFF0000
278 * All Windows Sockets error constants are biased by WSABASEERR from
279 * the "normal"
281 #define WSABASEERR 10000
283 * Windows Sockets definitions of regular Microsoft C error constants
285 #define WSAEINTR (WSABASEERR+4)
286 #define WSAEBADF (WSABASEERR+9)
287 #define WSAEACCES (WSABASEERR+13)
288 #define WSAEFAULT (WSABASEERR+14)
289 #define WSAEINVAL (WSABASEERR+22)
290 #define WSAEMFILE (WSABASEERR+24)
293 * Windows Sockets definitions of regular Berkeley error constants
295 #define WSAEWOULDBLOCK (WSABASEERR+35)
296 #define WSAEINPROGRESS (WSABASEERR+36)
297 #define WSAEALREADY (WSABASEERR+37)
298 #define WSAENOTSOCK (WSABASEERR+38)
299 #define WSAEDESTADDRREQ (WSABASEERR+39)
300 #define WSAEMSGSIZE (WSABASEERR+40)
301 #define WSAEPROTOTYPE (WSABASEERR+41)
302 #define WSAENOPROTOOPT (WSABASEERR+42)
303 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
304 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
305 #define WSAEOPNOTSUPP (WSABASEERR+45)
306 #define WSAEPFNOSUPPORT (WSABASEERR+46)
307 #define WSAEAFNOSUPPORT (WSABASEERR+47)
308 #define WSAEADDRINUSE (WSABASEERR+48)
309 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
310 #define WSAENETDOWN (WSABASEERR+50)
311 #define WSAENETUNREACH (WSABASEERR+51)
312 #define WSAENETRESET (WSABASEERR+52)
313 #define WSAECONNABORTED (WSABASEERR+53)
314 #define WSAECONNRESET (WSABASEERR+54)
315 #define WSAENOBUFS (WSABASEERR+55)
316 #define WSAEISCONN (WSABASEERR+56)
317 #define WSAENOTCONN (WSABASEERR+57)
318 #define WSAESHUTDOWN (WSABASEERR+58)
319 #define WSAETOOMANYREFS (WSABASEERR+59)
320 #define WSAETIMEDOUT (WSABASEERR+60)
321 #define WSAECONNREFUSED (WSABASEERR+61)
322 #define WSAELOOP (WSABASEERR+62)
323 #define WSAENAMETOOLONG (WSABASEERR+63)
324 #define WSAEHOSTDOWN (WSABASEERR+64)
325 #define WSAEHOSTUNREACH (WSABASEERR+65)
326 #define WSAENOTEMPTY (WSABASEERR+66)
327 #define WSAEPROCLIM (WSABASEERR+67)
328 #define WSAEUSERS (WSABASEERR+68)
329 #define WSAEDQUOT (WSABASEERR+69)
330 #define WSAESTALE (WSABASEERR+70)
331 #define WSAEREMOTE (WSABASEERR+71)
334 * Extended Windows Sockets error constant definitions
336 #define WSASYSNOTREADY (WSABASEERR+91)
337 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
338 #define WSANOTINITIALISED (WSABASEERR+93)
341 * Error return codes from gethostbyname() and gethostbyaddr()
342 * (when using the resolver). Note that these errors are
343 * retrieved via WSAGetLastError() and must therefore follow
344 * the rules for avoiding clashes with error numbers from
345 * specific implementations or language run-time systems.
346 * For this reason the codes are based at WSABASEERR+1001.
347 * Note also that [WSA]NO_ADDRESS is defined only for
348 * compatibility purposes.
351 /* #define h_errno WSAGetLastError() */
353 /* Authoritative Answer: Host not found */
354 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
356 /* Non-Authoritative: Host not found, or SERVERFAIL */
357 #define WSATRY_AGAIN (WSABASEERR+1002)
359 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
360 #define WSANO_RECOVERY (WSABASEERR+1003)
362 /* Valid name, no data record of requested type */
363 #define WSANO_DATA (WSABASEERR+1004)
365 /* no address, look for MX record */
366 #define WSANO_ADDRESS WSANO_DATA
368 /* Socket function prototypes */
370 #ifdef __cplusplus
371 extern "C" {
372 #endif
374 /* Microsoft Windows Extension function prototypes */
376 INT16 WINAPI WSAStartup16(UINT16 wVersionRequired, LPWSADATA lpWSAData);
377 INT WINAPI WSAStartup(UINT wVersionRequired, LPWSADATA lpWSAData);
378 void WINAPI WSASetLastError16(INT16 iError);
379 void WINAPI WSASetLastError(INT iError);
380 INT WINAPI WSACleanup(void);
381 INT WINAPI WSAGetLastError(void);
382 BOOL WINAPI WSAIsBlocking(void);
383 INT WINAPI WSACancelBlockingCall(void);
384 INT16 WINAPI WSAUnhookBlockingHook16(void);
385 INT WINAPI WSAUnhookBlockingHook(void);
386 FARPROC16 WINAPI WSASetBlockingHook16(FARPROC16 lpBlockFunc);
387 FARPROC WINAPI WSASetBlockingHook(FARPROC lpBlockFunc);
389 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 wMsg, LPCSTR name, LPCSTR proto,
390 SEGPTR buf, INT16 buflen);
391 HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, LPCSTR proto,
392 LPSTR sbuf, INT buflen);
394 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 wMsg, INT16 port,
395 LPCSTR proto, SEGPTR buf, INT16 buflen);
396 HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
397 LPCSTR proto, LPSTR sbuf, INT buflen);
399 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 wMsg,
400 LPCSTR name, SEGPTR buf, INT16 buflen);
401 HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg,
402 LPCSTR name, LPSTR sbuf, INT buflen);
404 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd, UINT16 wMsg,
405 INT16 number, SEGPTR buf, INT16 buflen);
406 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg,
407 INT number, LPSTR sbuf, INT buflen);
409 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 wMsg,
410 LPCSTR name, SEGPTR buf, INT16 buflen);
411 HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg,
412 LPCSTR name, LPSTR sbuf, INT buflen);
414 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 wMsg, LPCSTR addr,
415 INT16 len, INT16 type, SEGPTR buf, INT16 buflen);
416 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
417 INT len, INT type, LPSTR sbuf, INT buflen);
419 INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle);
420 INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
422 INT16 WINAPI WSAAsyncSelect16(SOCKET16 s, HWND16 hWnd, UINT16 wMsg, UINT lEvent);
423 INT WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, UINT lEvent);
427 * Address families
429 #define WS_AF_UNSPEC 0 /* unspecified */
430 #define WS_AF_UNIX 1 /* local to host (pipes, portals) */
431 #define WS_AF_INET 2 /* internetwork: UDP, TCP, etc. */
432 #define WS_AF_IMPLINK 3 /* arpanet imp addresses */
433 #define WS_AF_PUP 4 /* pup protocols: e.g. BSP */
434 #define WS_AF_CHAOS 5 /* mit CHAOS protocols */
435 #define WS_AF_NS 6 /* XEROX NS protocols */
436 #define WS_AF_IPX WS_AF_NS /* IPX protocols: IPX, SPX, etc. */
437 #define WS_AF_ISO 7 /* ISO protocols */
438 #define WS_AF_OSI AF_ISO /* OSI is ISO */
439 #define WS_AF_ECMA 8 /* european computer manufacturers */
440 #define WS_AF_DATAKIT 9 /* datakit protocols */
441 #define WS_AF_CCITT 10 /* CCITT protocols, X.25 etc */
442 #define WS_AF_SNA 11 /* IBM SNA */
443 #define WS_AF_DECnet 12 /* DECnet */
444 #define WS_AF_DLI 13 /* Direct data link interface */
445 #define WS_AF_LAT 14 /* LAT */
446 #define WS_AF_HYLINK 15 /* NSC Hyperchannel */
447 #define WS_AF_APPLETALK 16 /* AppleTalk */
448 #define WS_AF_NETBIOS 17 /* NetBios-style addresses */
449 #define WS_AF_VOICEVIEW 18 /* VoiceView */
450 #define WS_AF_FIREFOX 19 /* Protocols from Firefox */
451 #define WS_AF_UNKNOWN1 20 /* Somebody is using this! */
452 #define WS_AF_BAN 21 /* Banyan */
453 #define WS_AF_ATM 22 /* Native ATM Services */
454 #define WS_AF_INET6 23 /* Internetwork Version 6 */
455 #define WS_AF_CLUSTER 24 /* Microsoft Wolfpack */
456 #define WS_AF_12844 25 /* IEEE 1284.4 WG AF */
457 #define WS_AF_IRDA 26 /* IrDA */
459 #define WS_AF_MAX 27
461 struct ws_sockaddr_ipx
463 INT16 sipx_family __attribute__((packed));
464 UINT sipx_network __attribute__((packed));
465 CHAR sipx_node[6] __attribute__((packed));
466 UINT16 sipx_port __attribute__((packed));
469 #ifdef __cplusplus
471 #endif
473 /* Microsoft Windows Extended data types */
474 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
475 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
476 typedef struct linger LINGER, *PLINGER, *LPLINGER;
477 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
478 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
479 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
480 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
481 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
482 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
485 * Windows message parameter composition and decomposition
486 * macros.
488 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
489 * when constructing the response to a WSAAsyncGetXByY() routine.
491 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
493 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
494 * when constructing the response to WSAAsyncSelect().
496 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
498 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
499 * to extract the buffer length from the lParam in the response
500 * to a WSAGetXByY().
502 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
504 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
505 * to extract the error code from the lParam in the response
506 * to a WSAGetXByY().
508 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
510 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
511 * to extract the event code from the lParam in the response
512 * to a WSAAsyncSelect().
514 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
516 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
517 * to extract the error code from the lParam in the response
518 * to a WSAAsyncSelect().
520 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
522 /* ----------------------------------- internal structures */
524 /* ws_... struct conversion flags */
526 #define WS_DUP_LINEAR 0x0001
527 #define WS_DUP_NATIVE 0x0000 /* not used anymore */
528 #define WS_DUP_OFFSET 0x0002 /* internal pointers are offsets */
529 #define WS_DUP_SEGPTR 0x0004 /* internal pointers are SEGPTRs */
530 /* by default, internal pointers are linear */
531 /* async DNS op flags */
533 #define AOP_IO 0x0000001 /* aop_control paramaters */
535 #define AOP_CONTROL_REMOVE 0x0000000 /* aop_control return values */
536 #define AOP_CONTROL_KEEP 0x0000001
538 typedef struct __aop
540 /* AOp header */
542 struct __aop *next, *prev;
543 int fd[2]; /* pipe */
544 int (*aop_control)(struct __aop*, int); /* SIGIO handler */
545 pid_t pid; /* child process pid */
547 /* custom data */
549 HWND hWnd; /* hWnd to post */
550 UINT uMsg; /* uMsg message to. */
552 union
554 SEGPTR seg_base;
555 LPSTR lin_base;
556 void* ptr_base;
557 } b; /* buffer to copy result to */
559 UINT buflen;
560 UINT flags; /* WSMSG_ASYNC_... */
561 } ws_async_op;
563 #define WSMSG_ASYNC_HOSTBYNAME 0x0001
564 #define WSMSG_ASYNC_HOSTBYADDR 0x0002
565 #define WSMSG_ASYNC_PROTOBYNAME 0x0010
566 #define WSMSG_ASYNC_PROTOBYNUM 0x0020
567 #define WSMSG_ASYNC_SERVBYNAME 0x0100
568 #define WSMSG_ASYNC_SERVBYPORT 0x0200
569 #define WSMSG_ASYNC_RQMASK 0x0fff
571 #define WSMSG_WIN32_AOP 0x1000
572 #define WSMSG_DEAD_AOP 0x8000
574 typedef struct __sop /* WSAAsyncSelect() control struct */
576 struct __sop *next, *prev;
578 struct __ws* pws;
579 HWND hWnd;
580 UINT uMsg;
581 } ws_select_op;
583 typedef struct __ws /* socket */
585 int fd;
586 unsigned flags;
587 ws_select_op* psop;
588 } ws_socket;
590 #define WS_MAX_SOCKETS_PER_PROCESS 16
591 #define WS_MAX_UDP_DATAGRAM 1024
593 #define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
594 #define WSI_BLOCKINGHOOK 0x00000002 /* 32-bit callback */
596 typedef struct _WSINFO
598 struct _WSINFO* prev,*next;
600 unsigned flags;
601 INT err; /* WSAGetLastError() return value */
602 INT16 num_startup; /* reference counter */
603 INT16 num_async_rq;
604 INT16 last_free; /* entry in the socket table */
605 UINT16 buflen;
606 char* buffer; /* allocated from SEGPTR heap */
607 struct ws_hostent *he;
608 int helen;
609 struct ws_servent *se;
610 int selen;
611 struct ws_protoent *pe;
612 int pelen;
613 char* dbuffer; /* buffer for dummies (32 bytes) */
615 ws_socket sock[WS_MAX_SOCKETS_PER_PROCESS];
616 DWORD blocking_hook;
617 HTASK16 tid; /* owning task id - process might be better */
618 } WSINFO, *LPWSINFO;
620 /* function prototypes */
621 int WS_dup_he(LPWSINFO pwsi, struct hostent* p_he, int flag);
622 int WS_dup_pe(LPWSINFO pwsi, struct protoent* p_pe, int flag);
623 int WS_dup_se(LPWSINFO pwsi, struct servent* p_se, int flag);
625 void WS_do_async_gethost(LPWSINFO, unsigned);
626 void WS_do_async_getproto(LPWSINFO, unsigned);
627 void WS_do_async_getserv(LPWSINFO, unsigned);
629 /* winsock_dns.c */
630 extern HANDLE16 __WSAsyncDBQuery(LPWSINFO pwsi, HWND hWnd, UINT uMsg,
631 INT type, LPCSTR init, INT len, LPCSTR proto, void* sbuf,
632 INT buflen, UINT flag);
634 int WINSOCK_async_io(int fd, int async);
635 int WINSOCK_unblock_io(int fd, int noblock);
637 int WINSOCK_check_async_op(ws_async_op* p_aop);
638 void WINSOCK_link_async_op(ws_async_op* p_aop);
639 void WINSOCK_unlink_async_op(ws_async_op* p_aop);
640 int WINSOCK_cancel_async_op(ws_async_op* p_aop);
642 void WINSOCK_cancel_task_aops(HTASK16, void (*__memfree)(void*) );
644 BOOL WINSOCK_HandleIO(int* fd_max, int num_pending, fd_set pending_set[3], fd_set master_set[3] );
645 void WINSOCK_Shutdown(void);
646 UINT16 wsaErrno(void);
647 UINT16 wsaHerrno(void);
649 extern INT WINSOCK_DeleteTaskWSI( TDB* pTask, struct _WSINFO* );
651 #endif /* _WINSOCKAPI_ */