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