Added missing #include "config.h"
[wine/multimedia.git] / include / winsock.h
blob363615bb21cf8b29a4c5cdabc5ecb423cac3d372
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>
17 #include "windows.h"
18 #include "task.h"
20 #pragma pack(1)
22 /* Win16 socket-related types */
24 typedef UINT16 SOCKET16;
25 typedef UINT32 SOCKET32;
27 typedef struct ws_hostent
29 SEGPTR h_name; /* official name of host */
30 SEGPTR h_aliases; /* alias list */
31 INT16 h_addrtype; /* host address type */
32 INT16 h_length; /* length of address */
33 SEGPTR h_addr_list; /* list of addresses from name server */
34 } _ws_hostent;
36 typedef struct ws_protoent
38 SEGPTR p_name; /* official protocol name */
39 SEGPTR p_aliases; /* alias list */
40 INT16 p_proto; /* protocol # */
41 } _ws_protoent;
43 typedef struct ws_servent
45 SEGPTR s_name; /* official service name */
46 SEGPTR s_aliases; /* alias list */
47 INT16 s_port; /* port # */
48 SEGPTR s_proto; /* protocol to use */
49 } _ws_servent;
51 typedef struct ws_netent
53 SEGPTR n_name; /* official name of net */
54 SEGPTR n_aliases; /* alias list */
55 INT16 n_addrtype; /* net address type */
56 INT32 n_net; /* network # */
57 } _ws_netent;
59 typedef struct sockaddr ws_sockaddr;
61 typedef struct
63 UINT16 fd_count; /* how many are SET? */
64 SOCKET16 fd_array[FD_SETSIZE]; /* an array of SOCKETs */
65 } ws_fd_set16;
67 typedef struct
69 UINT32 fd_count; /* how many are SET? */
70 SOCKET32 fd_array[FD_SETSIZE]; /* an array of SOCKETs */
71 } ws_fd_set32;
73 /* ws_fd_set operations */
75 INT16 WINAPI __WSAFDIsSet16( SOCKET16, ws_fd_set16 * );
76 INT32 WINAPI __WSAFDIsSet32( SOCKET32, ws_fd_set32 * );
77 #define __WSAFDIsSet WINELIB_NAME(__WSAFDIsSet);
79 #define __WS_FD_CLR(fd, set, cast) do { \
80 UINT16 __i; \
81 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
82 { \
83 if (((cast*)(set))->fd_array[__i] == fd) \
84 { \
85 while (__i < ((cast*)(set))->fd_count-1) \
86 { \
87 ((cast*)(set))->fd_array[__i] = \
88 ((cast*)(set))->fd_array[__i+1]; \
89 __i++; \
90 } \
91 ((cast*)(set))->fd_count--; \
92 break; \
93 } \
94 } \
95 } while(0)
96 #define WS_FD_CLR16(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set16)
97 #define WS_FD_CLR32(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set32)
98 #define WS_FD_CLR WINELIB_NAME(WS_FD_CLR);
100 #define __WS_FD_SET(fd, set, cast) do { \
101 if (((cast*)(set))->fd_count < FD_SETSIZE) \
102 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\
103 } while(0)
104 #define WS_FD_SET16(fd, set) __WS_FD_SET((fd),(set), ws_fd_set16)
105 #define WS_FD_SET32(fd, set) __WS_FD_SET((fd),(set), ws_fd_set32)
106 #define WS_FD_SET WINELIB_NAME(WS_FD_SET);
108 #define WS_FD_ZERO16(set) (((ws_fd_set16*)(set))->fd_count=0)
109 #define WS_FD_ZERO32(set) (((ws_fd_set32*)(set))->fd_count=0)
110 #define WS_FD_ZERO WINELIB_NAME(WS_FD_ZERO);
112 #define WS_FD_ISSET16(fd, set) __WSAFDIsSet16((SOCKET16)(fd), (ws_fd_set16*)(set))
113 #define WS_FD_ISSET32(fd, set) __WSAFDIsSet32((SOCKET32)(fd), (ws_fd_set32*)(set))
114 #define WS_FD_ISSET WINELIB_NAME(WS_FD_ISSET);
117 * Internet address (old style... should be updated)
120 struct ws_in_addr
122 union {
123 struct { BYTE s_b1,s_b2,s_b3,s_b4; } S_un_b;
124 struct { UINT16 s_w1,s_w2; } S_un_w;
125 UINT32 S_addr;
126 } S_un;
127 #define ws_addr S_un.S_addr /* can be used for most tcp & ip code */
128 #define ws_host S_un.S_un_b.s_b2 /* host on imp */
129 #define ws_net S_un.S_un_b.s_b1 /* network */
130 #define ws_imp S_un.S_un_w.s_w2 /* imp */
131 #define ws_impno S_un.S_un_b.s_b4 /* imp # */
132 #define ws_lh S_un.S_un_b.s_b3 /* logical host */
135 struct ws_sockaddr_in
137 INT16 sin_family;
138 UINT16 sin_port;
139 struct ws_in_addr sin_addr;
140 BYTE sin_zero[8];
143 #define WSADESCRIPTION_LEN 256
144 #define WSASYS_STATUS_LEN 128
146 typedef struct WSAData {
147 WORD wVersion;
148 WORD wHighVersion;
149 char szDescription[WSADESCRIPTION_LEN+1];
150 char szSystemStatus[WSASYS_STATUS_LEN+1];
151 UINT16 iMaxSockets;
152 UINT16 iMaxUdpDg;
153 SEGPTR lpVendorInfo;
154 } WSADATA, *LPWSADATA;
156 #pragma pack(4)
158 /* ----------------------------------- no Win16 structure defs beyond this line! */
161 * This is used instead of -1, since the
162 * SOCKET type is unsigned.
164 #define INVALID_SOCKET16 (~0)
165 #define INVALID_SOCKET32 (~0)
166 #define SOCKET_ERROR (-1)
168 DECL_WINELIB_TYPE(INVALID_SOCKET)
169 DECL_WINELIB_TYPE(SOCKET)
172 * Types
174 #define WS_SOCK_STREAM 1 /* stream socket */
175 #define WS_SOCK_DGRAM 2 /* datagram socket */
176 #define WS_SOCK_RAW 3 /* raw-protocol interface */
177 #define WS_SOCK_RDM 4 /* reliably-delivered message */
178 #define WS_SOCK_SEQPACKET 5 /* sequenced packet stream */
180 #define WS_SOL_SOCKET 0xffff
181 #define WS_IPPROTO_TCP 6
184 * Option flags per-socket.
186 #define WS_SO_DEBUG 0x0001 /* turn on debugging info recording */
187 #define WS_SO_ACCEPTCONN 0x0002 /* socket has had listen() */
188 #define WS_SO_REUSEADDR 0x0004 /* allow local address reuse */
189 #define WS_SO_KEEPALIVE 0x0008 /* keep connections alive */
190 #define WS_SO_DONTROUTE 0x0010 /* just use interface addresses */
191 #define WS_SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
192 #define WS_SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
193 #define WS_SO_LINGER 0x0080 /* linger on close if data present */
194 #define WS_SO_OOBINLINE 0x0100 /* leave received OOB data in line */
196 #define WS_SO_DONTLINGER (UINT32)(~WS_SO_LINGER)
199 * Additional options.
201 #define WS_SO_SNDBUF 0x1001 /* send buffer size */
202 #define WS_SO_RCVBUF 0x1002 /* receive buffer size */
203 #define WS_SO_SNDLOWAT 0x1003 /* send low-water mark */
204 #define WS_SO_RCVLOWAT 0x1004 /* receive low-water mark */
205 #define WS_SO_SNDTIMEO 0x1005 /* send timeout */
206 #define WS_SO_RCVTIMEO 0x1006 /* receive timeout */
207 #define WS_SO_ERROR 0x1007 /* get error status and clear */
208 #define WS_SO_TYPE 0x1008 /* get socket type */
210 #define WS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
211 #define WS_IOC_VOID 0x20000000 /* no parameters */
212 #define WS_IOC_OUT 0x40000000 /* copy out parameters */
213 #define WS_IOC_IN 0x80000000 /* copy in parameters */
214 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
215 #define WS_IOR(x,y,t) (WS_IOC_OUT|(((UINT32)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
216 #define WS_IOW(x,y,t) (WS_IOC_IN|(((UINT32)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
219 * Socket I/O flags (supported by spec 1.1)
222 #define WS_FIONREAD WS_IOR('f', 127, u_long)
223 #define WS_FIONBIO WS_IOW('f', 126, u_long)
225 #define WS_SIOCATMARK WS_IOR('s', 7, u_long)
228 * Maximum queue length specifiable by listen.
230 #ifdef SOMAXCONN
231 #undef SOMAXCONN
232 #endif
233 #define SOMAXCONN 5
235 #ifndef MSG_DONTROUTE
236 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
237 #endif
238 #define MSG_MAXIOVLEN 16
241 * Define constant based on rfc883, used by gethostbyxxxx() calls.
243 #define MAXGETHOSTSTRUCT 1024
246 * Define flags to be used with the WSAAsyncSelect() call.
248 #define WS_FD_READ 0x0001
249 #define WS_FD_WRITE 0x0002
250 #define WS_FD_OOB 0x0004
251 #define WS_FD_ACCEPT 0x0008
252 #define WS_FD_CONNECT 0x0010
253 #define WS_FD_CLOSE 0x0020
255 #define WS_FD_LISTENING 0x10000000 /* internal per-socket flags */
256 #define WS_FD_INACTIVE 0x20000000
257 #define WS_FD_CONNECTED 0x40000000
258 #define WS_FD_RAW 0x80000000
259 #define WS_FD_INTERNAL 0xFFFF0000
262 * All Windows Sockets error constants are biased by WSABASEERR from
263 * the "normal"
265 #define WSABASEERR 10000
267 * Windows Sockets definitions of regular Microsoft C error constants
269 #define WSAEINTR (WSABASEERR+4)
270 #define WSAEBADF (WSABASEERR+9)
271 #define WSAEACCES (WSABASEERR+13)
272 #define WSAEFAULT (WSABASEERR+14)
273 #define WSAEINVAL (WSABASEERR+22)
274 #define WSAEMFILE (WSABASEERR+24)
277 * Windows Sockets definitions of regular Berkeley error constants
279 #define WSAEWOULDBLOCK (WSABASEERR+35)
280 #define WSAEINPROGRESS (WSABASEERR+36)
281 #define WSAEALREADY (WSABASEERR+37)
282 #define WSAENOTSOCK (WSABASEERR+38)
283 #define WSAEDESTADDRREQ (WSABASEERR+39)
284 #define WSAEMSGSIZE (WSABASEERR+40)
285 #define WSAEPROTOTYPE (WSABASEERR+41)
286 #define WSAENOPROTOOPT (WSABASEERR+42)
287 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
288 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
289 #define WSAEOPNOTSUPP (WSABASEERR+45)
290 #define WSAEPFNOSUPPORT (WSABASEERR+46)
291 #define WSAEAFNOSUPPORT (WSABASEERR+47)
292 #define WSAEADDRINUSE (WSABASEERR+48)
293 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
294 #define WSAENETDOWN (WSABASEERR+50)
295 #define WSAENETUNREACH (WSABASEERR+51)
296 #define WSAENETRESET (WSABASEERR+52)
297 #define WSAECONNABORTED (WSABASEERR+53)
298 #define WSAECONNRESET (WSABASEERR+54)
299 #define WSAENOBUFS (WSABASEERR+55)
300 #define WSAEISCONN (WSABASEERR+56)
301 #define WSAENOTCONN (WSABASEERR+57)
302 #define WSAESHUTDOWN (WSABASEERR+58)
303 #define WSAETOOMANYREFS (WSABASEERR+59)
304 #define WSAETIMEDOUT (WSABASEERR+60)
305 #define WSAECONNREFUSED (WSABASEERR+61)
306 #define WSAELOOP (WSABASEERR+62)
307 #define WSAENAMETOOLONG (WSABASEERR+63)
308 #define WSAEHOSTDOWN (WSABASEERR+64)
309 #define WSAEHOSTUNREACH (WSABASEERR+65)
310 #define WSAENOTEMPTY (WSABASEERR+66)
311 #define WSAEPROCLIM (WSABASEERR+67)
312 #define WSAEUSERS (WSABASEERR+68)
313 #define WSAEDQUOT (WSABASEERR+69)
314 #define WSAESTALE (WSABASEERR+70)
315 #define WSAEREMOTE (WSABASEERR+71)
318 * Extended Windows Sockets error constant definitions
320 #define WSASYSNOTREADY (WSABASEERR+91)
321 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
322 #define WSANOTINITIALISED (WSABASEERR+93)
325 * Error return codes from gethostbyname() and gethostbyaddr()
326 * (when using the resolver). Note that these errors are
327 * retrieved via WSAGetLastError() and must therefore follow
328 * the rules for avoiding clashes with error numbers from
329 * specific implementations or language run-time systems.
330 * For this reason the codes are based at WSABASEERR+1001.
331 * Note also that [WSA]NO_ADDRESS is defined only for
332 * compatibility purposes.
335 /* #define h_errno WSAGetLastError() */
337 /* Authoritative Answer: Host not found */
338 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
340 /* Non-Authoritative: Host not found, or SERVERFAIL */
341 #define WSATRY_AGAIN (WSABASEERR+1002)
343 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
344 #define WSANO_RECOVERY (WSABASEERR+1003)
346 /* Valid name, no data record of requested type */
347 #define WSANO_DATA (WSABASEERR+1004)
349 /* no address, look for MX record */
350 #define WSANO_ADDRESS WSANO_DATA
352 /* Socket function prototypes */
354 #ifdef __cplusplus
355 extern "C" {
356 #endif
358 /* Microsoft Windows Extension function prototypes */
360 INT16 WINAPI WSAStartup16(UINT16 wVersionRequired, LPWSADATA lpWSAData);
361 INT32 WINAPI WSAStartup32(UINT32 wVersionRequired, LPWSADATA lpWSAData);
362 #define WSAStartup WINELIB_NAME(WSAStartup);
363 void WINAPI WSASetLastError16(INT16 iError);
364 void WINAPI WSASetLastError32(INT32 iError);
365 #define WSASetLastError WINELIB_NAME(WSASetLastError);
366 INT32 WINAPI WSACleanup(void);
367 INT32 WINAPI WSAGetLastError(void);
368 BOOL32 WINAPI WSAIsBlocking(void);
369 INT32 WINAPI WSACancelBlockingCall(void);
370 INT16 WINAPI WSAUnhookBlockingHook16(void);
371 INT32 WINAPI WSAUnhookBlockingHook32(void);
372 #define WSAUnhookBlockingHook WINELIB_NAME(WSAUnhookBlockingHook)
373 FARPROC16 WINAPI WSASetBlockingHook16(FARPROC16 lpBlockFunc);
374 FARPROC32 WINAPI WSASetBlockingHook32(FARPROC32 lpBlockFunc);
375 #define WSASetBlockingHook WINELIB_NAME(WSASetBlockingHook)
377 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 wMsg, LPCSTR name, LPCSTR proto,
378 SEGPTR buf, INT16 buflen);
379 HANDLE32 WINAPI WSAAsyncGetServByName32(HWND32 hWnd, UINT32 uMsg, LPCSTR name, LPCSTR proto,
380 LPSTR sbuf, INT32 buflen);
381 #define WSAAsyncGetServByName WINELIB_NAME(WSAAsyncGetServByName)
383 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 wMsg, INT16 port,
384 LPCSTR proto, SEGPTR buf, INT16 buflen);
385 HANDLE32 WINAPI WSAAsyncGetServByPort32(HWND32 hWnd, UINT32 uMsg, INT32 port,
386 LPCSTR proto, LPSTR sbuf, INT32 buflen);
387 #define WSAAsyncGetServByPort WINELIB_NAME(WSAAsyncGetServByPort)
389 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 wMsg,
390 LPCSTR name, SEGPTR buf, INT16 buflen);
391 HANDLE32 WINAPI WSAAsyncGetProtoByName32(HWND32 hWnd, UINT32 uMsg,
392 LPCSTR name, LPSTR sbuf, INT32 buflen);
393 #define WSAAsyncGetProtoByByName WINELIB_NAME(WSAAsyncGetProtoByByName)
395 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd, UINT16 wMsg,
396 INT16 number, SEGPTR buf, INT16 buflen);
397 HANDLE32 WINAPI WSAAsyncGetProtoByNumber32(HWND32 hWnd, UINT32 uMsg,
398 INT32 number, LPSTR sbuf, INT32 buflen);
399 #define WSAAsyncGetProtoByNumber WINELIB_NAME(WSAAsyncGetProtoByNumber)
401 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 wMsg,
402 LPCSTR name, SEGPTR buf, INT16 buflen);
403 HANDLE32 WINAPI WSAAsyncGetHostByName32(HWND32 hWnd, UINT32 uMsg,
404 LPCSTR name, LPSTR sbuf, INT32 buflen);
405 #define WSAAsyncGetHostByName WINELIB_NAME(WSAAsyncGetHostByName)
407 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 wMsg, LPCSTR addr,
408 INT16 len, INT16 type, SEGPTR buf, INT16 buflen);
409 HANDLE32 WINAPI WSAAsyncGetHostByAddr32(HWND32 hWnd, UINT32 uMsg, LPCSTR addr,
410 INT32 len, INT32 type, LPSTR sbuf, INT32 buflen);
411 #define WSAAsyncGetHostByAddr WINELIB_NAME(WSAAsyncGetHostByAddr)
413 INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle);
414 INT32 WINAPI WSACancelAsyncRequest32(HANDLE32 hAsyncTaskHandle);
415 #define WSACancelAsyncRequest WINELIB_NAME(WSACancelAsyncRequest)
417 INT16 WINAPI WSAAsyncSelect16(SOCKET16 s, HWND16 hWnd, UINT16 wMsg, UINT32 lEvent);
418 INT32 WINAPI WSAAsyncSelect32(SOCKET32 s, HWND32 hWnd, UINT32 uMsg, UINT32 lEvent);
419 #define WSAAsyncSelect WINELIB_NAME(WSAAsyncSelect)
422 #ifdef __cplusplus
424 #endif
426 /* Microsoft Windows Extended data types */
427 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
428 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
429 typedef struct linger LINGER, *PLINGER, *LPLINGER;
430 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
431 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
432 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
433 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
434 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
435 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
438 * Windows message parameter composition and decomposition
439 * macros.
441 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
442 * when constructing the response to a WSAAsyncGetXByY() routine.
444 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
446 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
447 * when constructing the response to WSAAsyncSelect().
449 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
451 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
452 * to extract the buffer length from the lParam in the response
453 * to a WSAGetXByY().
455 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
457 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
458 * to extract the error code from the lParam in the response
459 * to a WSAGetXByY().
461 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
463 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
464 * to extract the event code from the lParam in the response
465 * to a WSAAsyncSelect().
467 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
469 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
470 * to extract the error code from the lParam in the response
471 * to a WSAAsyncSelect().
473 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
475 /* ----------------------------------- internal structures */
477 /* ws_... struct conversion flags */
479 #define WS_DUP_LINEAR 0x0001
480 #define WS_DUP_NATIVE 0x0000 /* not used anymore */
481 #define WS_DUP_OFFSET 0x0002 /* internal pointers are offsets */
482 #define WS_DUP_SEGPTR 0x0004 /* internal pointers are SEGPTRs */
483 /* by default, internal pointers are linear */
484 /* async DNS op flags */
486 #define AOP_IO 0x0000001 /* aop_control paramaters */
488 #define AOP_CONTROL_REMOVE 0x0000000 /* aop_control return values */
489 #define AOP_CONTROL_KEEP 0x0000001
491 typedef struct __aop
493 /* AOp header */
495 struct __aop *next, *prev;
496 int fd[2]; /* pipe */
497 int (*aop_control)(struct __aop*, int); /* SIGIO handler */
498 pid_t pid; /* child process pid */
500 /* custom data */
502 HWND32 hWnd; /* hWnd to post */
503 UINT32 uMsg; /* uMsg message to. */
505 union
507 SEGPTR seg_base;
508 LPSTR lin_base;
509 void* ptr_base;
510 } b; /* buffer to copy result to */
512 UINT32 buflen;
513 UINT32 flags; /* WSMSG_ASYNC_... */
514 } ws_async_op;
516 #define WSMSG_ASYNC_HOSTBYNAME 0x0001
517 #define WSMSG_ASYNC_HOSTBYADDR 0x0002
518 #define WSMSG_ASYNC_PROTOBYNAME 0x0010
519 #define WSMSG_ASYNC_PROTOBYNUM 0x0020
520 #define WSMSG_ASYNC_SERVBYNAME 0x0100
521 #define WSMSG_ASYNC_SERVBYPORT 0x0200
522 #define WSMSG_ASYNC_RQMASK 0x0fff
524 #define WSMSG_WIN32_AOP 0x1000
525 #define WSMSG_DEAD_AOP 0x8000
527 typedef struct __sop /* WSAAsyncSelect() control struct */
529 struct __sop *next, *prev;
531 struct __ws* pws;
532 HWND32 hWnd;
533 UINT32 uMsg;
534 } ws_select_op;
536 typedef struct __ws /* socket */
538 int fd;
539 unsigned flags;
540 ws_select_op* psop;
541 } ws_socket;
543 #define WS_MAX_SOCKETS_PER_PROCESS 16
544 #define WS_MAX_UDP_DATAGRAM 1024
546 #define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
547 #define WSI_BLOCKINGHOOK32 0x00000002 /* 32-bit callback */
549 typedef struct _WSINFO
551 struct _WSINFO* prev,*next;
553 unsigned flags;
554 INT32 err; /* WSAGetLastError() return value */
555 INT16 num_startup; /* reference counter */
556 INT16 num_async_rq;
557 INT16 last_free; /* entry in the socket table */
558 UINT16 buflen;
559 char* buffer; /* allocated from SEGPTR heap */
560 struct ws_hostent *he;
561 int helen;
562 struct ws_servent *se;
563 int selen;
564 struct ws_protoent *pe;
565 int pelen;
566 char* dbuffer; /* buffer for dummies (32 bytes) */
568 ws_socket sock[WS_MAX_SOCKETS_PER_PROCESS];
569 DWORD blocking_hook;
570 HTASK16 tid; /* owning task id - process might be better */
571 } WSINFO, *LPWSINFO;
573 /* function prototypes */
574 int WS_dup_he(LPWSINFO pwsi, struct hostent* p_he, int flag);
575 int WS_dup_pe(LPWSINFO pwsi, struct protoent* p_pe, int flag);
576 int WS_dup_se(LPWSINFO pwsi, struct servent* p_se, int flag);
578 void WS_do_async_gethost(LPWSINFO, unsigned);
579 void WS_do_async_getproto(LPWSINFO, unsigned);
580 void WS_do_async_getserv(LPWSINFO, unsigned);
582 /* winsock_dns.c */
583 extern HANDLE16 __WSAsyncDBQuery(LPWSINFO pwsi, HWND32 hWnd, UINT32 uMsg,
584 INT32 type, LPCSTR init, INT32 len, LPCSTR proto, void* sbuf,
585 INT32 buflen, UINT32 flag);
587 int WINSOCK_async_io(int fd, int async);
588 int WINSOCK_unblock_io(int fd, int noblock);
590 int WINSOCK_check_async_op(ws_async_op* p_aop);
591 void WINSOCK_link_async_op(ws_async_op* p_aop);
592 void WINSOCK_unlink_async_op(ws_async_op* p_aop);
593 int WINSOCK_cancel_async_op(ws_async_op* p_aop);
595 void WINSOCK_cancel_task_aops(HTASK16, void (*__memfree)(void*) );
597 BOOL32 WINSOCK_HandleIO(int* fd_max, int num_pending, fd_set pending_set[3], fd_set master_set[3] );
598 void WINSOCK_Shutdown(void);
599 UINT16 wsaErrno(void);
600 UINT16 wsaHerrno(void);
602 extern INT32 WINSOCK_DeleteTaskWSI( TDB* pTask, struct _WSINFO* );
604 #endif /* _WINSOCKAPI_ */