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