FindResourceExA/W should search for the specified language resource only.
[wine.git] / include / winsock.h
blob390e1724cc9f22d429e4ad12ed63f4f4473ba1fa
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 <sys/types.h>
12 /* Solaris kludge */
13 #undef FSHIFT
14 #undef PAGESIZE
15 #undef TRANSPARENT
16 #include <netinet/in.h>
17 #undef FSHIFT
18 #undef PAGESIZE
19 #undef TRANSPARENT
21 #include <arpa/inet.h>
22 #include <sys/time.h>
23 #include <fcntl.h>
24 #include <netdb.h>
25 #include <sys/socket.h>
27 #ifdef HAVE_IPX_GNU
28 # include <netipx/ipx.h>
29 # define HAVE_IPX
30 #endif
32 #ifdef HAVE_IPX_LINUX
33 # include <asm/types.h>
34 # include <linux/ipx.h>
35 # define HAVE_IPX
36 #endif
38 #include "windef.h"
39 #include "task.h"
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* defined(__cplusplus) */
45 #include "pshpack1.h"
47 /* Win16 socket-related types */
49 typedef UINT16 SOCKET16;
50 typedef UINT SOCKET;
52 typedef struct ws_hostent
54 SEGPTR h_name; /* official name of host */
55 SEGPTR h_aliases; /* alias list */
56 INT16 h_addrtype; /* host address type */
57 INT16 h_length; /* length of address */
58 SEGPTR h_addr_list; /* list of addresses from name server */
59 } _ws_hostent;
61 typedef struct ws_protoent
63 SEGPTR p_name; /* official protocol name */
64 SEGPTR p_aliases; /* alias list */
65 INT16 p_proto; /* protocol # */
66 } _ws_protoent;
68 typedef struct ws_servent
70 SEGPTR s_name; /* official service name */
71 SEGPTR s_aliases; /* alias list */
72 INT16 s_port; /* port # */
73 SEGPTR s_proto; /* protocol to use */
74 } _ws_servent;
76 typedef struct ws_netent
78 SEGPTR n_name; /* official name of net */
79 SEGPTR n_aliases; /* alias list */
80 INT16 n_addrtype; /* net address type */
81 INT n_net; /* network # */
82 } _ws_netent;
84 typedef struct sockaddr ws_sockaddr;
86 typedef struct
88 UINT16 fd_count; /* how many are SET? */
89 SOCKET16 fd_array[FD_SETSIZE]; /* an array of SOCKETs */
90 } ws_fd_set16;
92 typedef struct
94 UINT fd_count; /* how many are SET? */
95 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
96 } ws_fd_set32;
98 /* ws_fd_set operations */
100 INT16 WINAPI __WSAFDIsSet16( SOCKET16, ws_fd_set16 * );
101 INT WINAPI __WSAFDIsSet( SOCKET, ws_fd_set32 * );
103 #define __WS_FD_CLR(fd, set, cast) do { \
104 UINT16 __i; \
105 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
107 if (((cast*)(set))->fd_array[__i] == fd) \
109 while (__i < ((cast*)(set))->fd_count-1) \
111 ((cast*)(set))->fd_array[__i] = \
112 ((cast*)(set))->fd_array[__i+1]; \
113 __i++; \
115 ((cast*)(set))->fd_count--; \
116 break; \
119 } while(0)
120 #define WS_FD_CLR16(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set16)
121 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set32)
123 #define __WS_FD_SET(fd, set, cast) do { \
124 if (((cast*)(set))->fd_count < FD_SETSIZE) \
125 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\
126 } while(0)
127 #define WS_FD_SET16(fd, set) __WS_FD_SET((fd),(set), ws_fd_set16)
128 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), ws_fd_set32)
130 #define WS_FD_ZERO16(set) (((ws_fd_set16*)(set))->fd_count=0)
131 #define WS_FD_ZERO(set) (((ws_fd_set32*)(set))->fd_count=0)
133 #define WS_FD_ISSET16(fd, set) __WSAFDIsSet16((SOCKET16)(fd), (ws_fd_set16*)(set))
134 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (ws_fd_set32*)(set))
137 * Internet address (old style... should be updated)
140 struct ws_in_addr
142 union {
143 struct { BYTE s_b1,s_b2,s_b3,s_b4; } S_un_b;
144 struct { UINT16 s_w1,s_w2; } S_un_w;
145 UINT S_addr;
146 } S_un;
147 #define ws_addr S_un.S_addr /* can be used for most tcp & ip code */
148 #define ws_host S_un.S_un_b.s_b2 /* host on imp */
149 #define ws_net S_un.S_un_b.s_b1 /* network */
150 #define ws_imp S_un.S_un_w.s_w2 /* imp */
151 #define ws_impno S_un.S_un_b.s_b4 /* imp # */
152 #define ws_lh S_un.S_un_b.s_b3 /* logical host */
155 struct ws_sockaddr_in
157 INT16 sin_family;
158 UINT16 sin_port;
159 struct ws_in_addr sin_addr;
160 BYTE sin_zero[8];
163 #define WSADESCRIPTION_LEN 256
164 #define WSASYS_STATUS_LEN 128
166 typedef struct WSAData {
167 WORD wVersion;
168 WORD wHighVersion;
169 char szDescription[WSADESCRIPTION_LEN+1];
170 char szSystemStatus[WSASYS_STATUS_LEN+1];
171 UINT16 iMaxSockets;
172 UINT16 iMaxUdpDg;
173 SEGPTR lpVendorInfo;
174 } WSADATA, *LPWSADATA;
176 #include "poppack.h"
178 /* ----------------------------------- no Win16 structure defs beyond this line! */
181 * This is used instead of -1, since the
182 * SOCKET type is unsigned.
184 #define INVALID_SOCKET16 (~0)
185 #define INVALID_SOCKET (~0)
186 #define SOCKET_ERROR (-1)
190 * Types
192 #define WS_SOCK_STREAM 1 /* stream socket */
193 #define WS_SOCK_DGRAM 2 /* datagram socket */
194 #define WS_SOCK_RAW 3 /* raw-protocol interface */
195 #define WS_SOCK_RDM 4 /* reliably-delivered message */
196 #define WS_SOCK_SEQPACKET 5 /* sequenced packet stream */
198 #define WS_SOL_SOCKET 0xffff
199 #define WS_IPPROTO_TCP 6
202 * Option flags per-socket.
204 #define WS_SO_DEBUG 0x0001 /* turn on debugging info recording */
205 #define WS_SO_ACCEPTCONN 0x0002 /* socket has had listen() */
206 #define WS_SO_REUSEADDR 0x0004 /* allow local address reuse */
207 #define WS_SO_KEEPALIVE 0x0008 /* keep connections alive */
208 #define WS_SO_DONTROUTE 0x0010 /* just use interface addresses */
209 #define WS_SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
210 #define WS_SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
211 #define WS_SO_LINGER 0x0080 /* linger on close if data present */
212 #define WS_SO_OOBINLINE 0x0100 /* leave received OOB data in line */
214 #define WS_SO_DONTLINGER (UINT)(~WS_SO_LINGER)
217 * Additional options.
219 #define WS_SO_SNDBUF 0x1001 /* send buffer size */
220 #define WS_SO_RCVBUF 0x1002 /* receive buffer size */
221 #define WS_SO_SNDLOWAT 0x1003 /* send low-water mark */
222 #define WS_SO_RCVLOWAT 0x1004 /* receive low-water mark */
223 #define WS_SO_SNDTIMEO 0x1005 /* send timeout */
224 #define WS_SO_RCVTIMEO 0x1006 /* receive timeout */
225 #define WS_SO_ERROR 0x1007 /* get error status and clear */
226 #define WS_SO_TYPE 0x1008 /* get socket type */
228 #define WS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
229 #define WS_IOC_VOID 0x20000000 /* no parameters */
230 #define WS_IOC_OUT 0x40000000 /* copy out parameters */
231 #define WS_IOC_IN 0x80000000 /* copy in parameters */
232 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
233 #define WS_IOR(x,y,t) (WS_IOC_OUT|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
234 #define WS_IOW(x,y,t) (WS_IOC_IN|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
236 /* IPPROTO_TCP options */
237 #define WS_TCP_NODELAY 1 /* do not apply nagle algorithm */
240 * Socket I/O flags (supported by spec 1.1)
243 #define WS_FIONREAD WS_IOR('f', 127, u_long)
244 #define WS_FIONBIO WS_IOW('f', 126, u_long)
246 #define WS_SIOCATMARK WS_IOR('s', 7, u_long)
249 * Maximum queue length specifiable by listen.
251 #ifdef SOMAXCONN
252 #undef SOMAXCONN
253 #endif
254 #define SOMAXCONN 5
256 #ifndef MSG_DONTROUTE
257 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
258 #endif
259 #define MSG_MAXIOVLEN 16
261 #ifndef MSG_PARTIAL
262 #define MSG_PARTIAL 0x8000 /* partial send or recv (WSARecvEx) */
263 #endif
266 * Define constant based on rfc883, used by gethostbyxxxx() calls.
268 #define MAXGETHOSTSTRUCT 1024
271 * Define flags to be used with the WSAAsyncSelect() call.
273 #define FD_READ WS_FD_READ
274 #define FD_WRITE WS_FD_WRITE
275 #define FD_OOB WS_FD_OOB
276 #define FD_ACCEPT WS_FD_ACCEPT
277 #define FD_CONNECT WS_FD_CONNECT
278 #define FD_CLOSE WS_FD_CLOSE
279 #define WS_FD_READ 0x0001
280 #define WS_FD_WRITE 0x0002
281 #define WS_FD_OOB 0x0004
282 #define WS_FD_ACCEPT 0x0008
283 #define WS_FD_CONNECT 0x0010
284 #define WS_FD_CLOSE 0x0020
286 #define WS_FD_LISTENING 0x10000000 /* internal per-socket flags */
287 #define WS_FD_NONBLOCKING 0x20000000
288 #define WS_FD_CONNECTED 0x40000000
289 #define WS_FD_RAW 0x80000000
290 #define WS_FD_SERVEVENT 0x01000000
291 #define WS_FD_INTERNAL 0xFFFF0000
294 * All Windows Sockets error constants are biased by WSABASEERR from
295 * the "normal"
297 #define WSABASEERR 10000
299 * Windows Sockets definitions of regular Microsoft C error constants
301 #define WSAEINTR (WSABASEERR+4)
302 #define WSAEBADF (WSABASEERR+9)
303 #define WSAEACCES (WSABASEERR+13)
304 #define WSAEFAULT (WSABASEERR+14)
305 #define WSAEINVAL (WSABASEERR+22)
306 #define WSAEMFILE (WSABASEERR+24)
309 * Windows Sockets definitions of regular Berkeley error constants
311 #define WSAEWOULDBLOCK (WSABASEERR+35)
312 #define WSAEINPROGRESS (WSABASEERR+36)
313 #define WSAEALREADY (WSABASEERR+37)
314 #define WSAENOTSOCK (WSABASEERR+38)
315 #define WSAEDESTADDRREQ (WSABASEERR+39)
316 #define WSAEMSGSIZE (WSABASEERR+40)
317 #define WSAEPROTOTYPE (WSABASEERR+41)
318 #define WSAENOPROTOOPT (WSABASEERR+42)
319 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
320 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
321 #define WSAEOPNOTSUPP (WSABASEERR+45)
322 #define WSAEPFNOSUPPORT (WSABASEERR+46)
323 #define WSAEAFNOSUPPORT (WSABASEERR+47)
324 #define WSAEADDRINUSE (WSABASEERR+48)
325 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
326 #define WSAENETDOWN (WSABASEERR+50)
327 #define WSAENETUNREACH (WSABASEERR+51)
328 #define WSAENETRESET (WSABASEERR+52)
329 #define WSAECONNABORTED (WSABASEERR+53)
330 #define WSAECONNRESET (WSABASEERR+54)
331 #define WSAENOBUFS (WSABASEERR+55)
332 #define WSAEISCONN (WSABASEERR+56)
333 #define WSAENOTCONN (WSABASEERR+57)
334 #define WSAESHUTDOWN (WSABASEERR+58)
335 #define WSAETOOMANYREFS (WSABASEERR+59)
336 #define WSAETIMEDOUT (WSABASEERR+60)
337 #define WSAECONNREFUSED (WSABASEERR+61)
338 #define WSAELOOP (WSABASEERR+62)
339 #define WSAENAMETOOLONG (WSABASEERR+63)
340 #define WSAEHOSTDOWN (WSABASEERR+64)
341 #define WSAEHOSTUNREACH (WSABASEERR+65)
342 #define WSAENOTEMPTY (WSABASEERR+66)
343 #define WSAEPROCLIM (WSABASEERR+67)
344 #define WSAEUSERS (WSABASEERR+68)
345 #define WSAEDQUOT (WSABASEERR+69)
346 #define WSAESTALE (WSABASEERR+70)
347 #define WSAEREMOTE (WSABASEERR+71)
350 * Extended Windows Sockets error constant definitions
352 #define WSASYSNOTREADY (WSABASEERR+91)
353 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
354 #define WSANOTINITIALISED (WSABASEERR+93)
357 * Error return codes from gethostbyname() and gethostbyaddr()
358 * (when using the resolver). Note that these errors are
359 * retrieved via WSAGetLastError() and must therefore follow
360 * the rules for avoiding clashes with error numbers from
361 * specific implementations or language run-time systems.
362 * For this reason the codes are based at WSABASEERR+1001.
363 * Note also that [WSA]NO_ADDRESS is defined only for
364 * compatibility purposes.
367 /* #define h_errno WSAGetLastError() */
369 /* Authoritative Answer: Host not found */
370 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
372 /* Non-Authoritative: Host not found, or SERVERFAIL */
373 #define WSATRY_AGAIN (WSABASEERR+1002)
375 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
376 #define WSANO_RECOVERY (WSABASEERR+1003)
378 /* Valid name, no data record of requested type */
379 #define WSANO_DATA (WSABASEERR+1004)
381 /* no address, look for MX record */
382 #define WSANO_ADDRESS WSANO_DATA
384 /* Socket function prototypes */
386 #ifdef __cplusplus
387 extern "C" {
388 #endif
390 /* Microsoft Windows Extension function prototypes */
392 INT16 WINAPI WSAStartup16(UINT16 wVersionRequired, LPWSADATA lpWSAData);
393 INT WINAPI WSAStartup(UINT wVersionRequired, LPWSADATA lpWSAData);
394 void WINAPI WSASetLastError16(INT16 iError);
395 void WINAPI WSASetLastError(INT iError);
396 INT WINAPI WSACleanup(void);
397 INT WINAPI WSAGetLastError(void);
398 BOOL WINAPI WSAIsBlocking(void);
399 INT WINAPI WSACancelBlockingCall(void);
400 INT16 WINAPI WSAUnhookBlockingHook16(void);
401 INT WINAPI WSAUnhookBlockingHook(void);
402 FARPROC16 WINAPI WSASetBlockingHook16(FARPROC16 lpBlockFunc);
403 FARPROC WINAPI WSASetBlockingHook(FARPROC lpBlockFunc);
405 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 wMsg, LPCSTR name, LPCSTR proto,
406 SEGPTR buf, INT16 buflen);
407 HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, LPCSTR proto,
408 LPSTR sbuf, INT buflen);
410 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 wMsg, INT16 port,
411 LPCSTR proto, SEGPTR buf, INT16 buflen);
412 HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
413 LPCSTR proto, LPSTR sbuf, INT buflen);
415 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 wMsg,
416 LPCSTR name, SEGPTR buf, INT16 buflen);
417 HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg,
418 LPCSTR name, LPSTR sbuf, INT buflen);
420 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd, UINT16 wMsg,
421 INT16 number, SEGPTR buf, INT16 buflen);
422 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg,
423 INT number, LPSTR sbuf, INT buflen);
425 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 wMsg,
426 LPCSTR name, SEGPTR buf, INT16 buflen);
427 HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg,
428 LPCSTR name, LPSTR sbuf, INT buflen);
430 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 wMsg, LPCSTR addr,
431 INT16 len, INT16 type, SEGPTR buf, INT16 buflen);
432 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
433 INT len, INT type, LPSTR sbuf, INT buflen);
435 INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle);
436 INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
438 INT16 WINAPI WSAAsyncSelect16(SOCKET16 s, HWND16 hWnd, UINT16 wMsg, LONG lEvent);
439 INT WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, LONG lEvent);
441 INT16 WINAPI WSARecvEx16(SOCKET16 s, char *buf, INT16 len, INT16 *flags);
442 INT WINAPI WSARecvEx(SOCKET s, char *buf, INT len, INT *flags);
445 * Address families
447 #define WS_AF_UNSPEC 0 /* unspecified */
448 #define WS_AF_UNIX 1 /* local to host (pipes, portals) */
449 #define WS_AF_INET 2 /* internetwork: UDP, TCP, etc. */
450 #define WS_AF_IMPLINK 3 /* arpanet imp addresses */
451 #define WS_AF_PUP 4 /* pup protocols: e.g. BSP */
452 #define WS_AF_CHAOS 5 /* mit CHAOS protocols */
453 #define WS_AF_NS 6 /* XEROX NS protocols */
454 #define WS_AF_IPX WS_AF_NS /* IPX protocols: IPX, SPX, etc. */
455 #define WS_AF_ISO 7 /* ISO protocols */
456 #define WS_AF_OSI AF_ISO /* OSI is ISO */
457 #define WS_AF_ECMA 8 /* european computer manufacturers */
458 #define WS_AF_DATAKIT 9 /* datakit protocols */
459 #define WS_AF_CCITT 10 /* CCITT protocols, X.25 etc */
460 #define WS_AF_SNA 11 /* IBM SNA */
461 #define WS_AF_DECnet 12 /* DECnet */
462 #define WS_AF_DLI 13 /* Direct data link interface */
463 #define WS_AF_LAT 14 /* LAT */
464 #define WS_AF_HYLINK 15 /* NSC Hyperchannel */
465 #define WS_AF_APPLETALK 16 /* AppleTalk */
466 #define WS_AF_NETBIOS 17 /* NetBios-style addresses */
467 #define WS_AF_VOICEVIEW 18 /* VoiceView */
468 #define WS_AF_FIREFOX 19 /* Protocols from Firefox */
469 #define WS_AF_UNKNOWN1 20 /* Somebody is using this! */
470 #define WS_AF_BAN 21 /* Banyan */
471 #define WS_AF_ATM 22 /* Native ATM Services */
472 #define WS_AF_INET6 23 /* Internetwork Version 6 */
473 #define WS_AF_CLUSTER 24 /* Microsoft Wolfpack */
474 #define WS_AF_12844 25 /* IEEE 1284.4 WG AF */
475 #define WS_AF_IRDA 26 /* IrDA */
477 #define WS_AF_MAX 27
479 #include "pshpack1.h"
481 struct ws_sockaddr_ipx
483 INT16 sipx_family;
484 UINT sipx_network;
485 CHAR sipx_node[6];
486 UINT16 sipx_port;
489 #include "poppack.h"
491 #ifdef __cplusplus
493 #endif
495 /* Microsoft Windows Extended data types */
496 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
497 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
498 typedef struct linger LINGER, *PLINGER, *LPLINGER;
499 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
500 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
501 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
502 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
503 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
504 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
507 * Windows message parameter composition and decomposition
508 * macros.
510 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
511 * when constructing the response to a WSAAsyncGetXByY() routine.
513 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
515 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
516 * when constructing the response to WSAAsyncSelect().
518 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
520 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
521 * to extract the buffer length from the lParam in the response
522 * to a WSAGetXByY().
524 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
526 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
527 * to extract the error code from the lParam in the response
528 * to a WSAGetXByY().
530 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
532 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
533 * to extract the event code from the lParam in the response
534 * to a WSAAsyncSelect().
536 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
538 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
539 * to extract the error code from the lParam in the response
540 * to a WSAAsyncSelect().
542 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
544 #ifdef __cplusplus
545 } /* extern "C" */
546 #endif /* defined(__cplusplus) */
548 #endif /* _WINSOCKAPI_ */