Release 960114
[wine/gsoc-2012-control.git] / include / winsock.h
blob56a8fadfafddf350ad68de749c8d0a7f956ac3f6
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 <arpa/inet.h>
11 #include <sys/types.h>
12 #include <sys/time.h>
13 #include <fcntl.h>
14 #include <netdb.h>
15 #include <netinet/in.h>
16 #include <sys/socket.h>
17 #include "windows.h"
20 * The new type to be used in all
21 * instances which refer to sockets.
23 typedef u_int SOCKET;
25 extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);
28 * Internet address (old style... should be updated)
30 #ifdef WS_USE_OLD_STYLE
31 #define s_addr S_un.S_addr /* can be used for most tcp & ip code */
32 #define s_host S_un.S_un_b.s_b2 /* host on imp */
33 #define s_net S_un.S_un_b.s_b1 /* network */
34 #define s_imp S_un.S_un_w.s_w2 /* imp */
35 #define s_impno S_un.S_un_b.s_b4 /* imp # */
36 #define s_lh S_un.S_un_b.s_b3 /* logical host */
37 #endif
39 #define WSADESCRIPTION_LEN 256
40 #define WSASYS_STATUS_LEN 128
42 typedef struct WSAData {
43 WORD wVersion;
44 WORD wHighVersion;
45 char szDescription[WSADESCRIPTION_LEN+1];
46 char szSystemStatus[WSASYS_STATUS_LEN+1];
47 unsigned short iMaxSockets;
48 unsigned short iMaxUdpDg;
49 char FAR * lpVendorInfo;
50 } WSADATA;
52 typedef WSADATA FAR *LPWSADATA;
55 * This is used instead of -1, since the
56 * SOCKET type is unsigned.
58 #define INVALID_SOCKET (SOCKET)(~0)
59 #define SOCKET_ERROR (-1)
62 * Option flags per-socket.
64 #ifndef SO_DONTLINGER
65 #define SO_DONTLINGER (u_int)(~SO_LINGER)
66 #endif
69 * Maximum queue length specifiable by listen.
71 #ifdef SOMAXCONN
72 #undef SOMAXCONN
73 #endif
74 #define SOMAXCONN 5
76 #ifndef MSG_DONTROUTE
77 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
78 #endif
79 #define MSG_MAXIOVLEN 16
82 * Define constant based on rfc883, used by gethostbyxxxx() calls.
84 #define MAXGETHOSTSTRUCT 1024
87 * Define flags to be used with the WSAAsyncSelect() call.
89 #define FD_READ 0x01
90 #define FD_WRITE 0x02
91 #define FD_OOB 0x04
92 #define FD_ACCEPT 0x08
93 #define FD_CONNECT 0x10
94 #define FD_CLOSE 0x20
97 * All Windows Sockets error constants are biased by WSABASEERR from
98 * the "normal"
100 #define WSABASEERR 10000
102 * Windows Sockets definitions of regular Microsoft C error constants
104 #define WSAEINTR (WSABASEERR+4)
105 #define WSAEBADF (WSABASEERR+9)
106 #define WSAEACCES (WSABASEERR+13)
107 #define WSAEFAULT (WSABASEERR+14)
108 #define WSAEINVAL (WSABASEERR+22)
109 #define WSAEMFILE (WSABASEERR+24)
112 * Windows Sockets definitions of regular Berkeley error constants
114 #define WSAEWOULDBLOCK (WSABASEERR+35)
115 #define WSAEINPROGRESS (WSABASEERR+36)
116 #define WSAEALREADY (WSABASEERR+37)
117 #define WSAENOTSOCK (WSABASEERR+38)
118 #define WSAEDESTADDRREQ (WSABASEERR+39)
119 #define WSAEMSGSIZE (WSABASEERR+40)
120 #define WSAEPROTOTYPE (WSABASEERR+41)
121 #define WSAENOPROTOOPT (WSABASEERR+42)
122 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
123 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
124 #define WSAEOPNOTSUPP (WSABASEERR+45)
125 #define WSAEPFNOSUPPORT (WSABASEERR+46)
126 #define WSAEAFNOSUPPORT (WSABASEERR+47)
127 #define WSAEADDRINUSE (WSABASEERR+48)
128 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
129 #define WSAENETDOWN (WSABASEERR+50)
130 #define WSAENETUNREACH (WSABASEERR+51)
131 #define WSAENETRESET (WSABASEERR+52)
132 #define WSAECONNABORTED (WSABASEERR+53)
133 #define WSAECONNRESET (WSABASEERR+54)
134 #define WSAENOBUFS (WSABASEERR+55)
135 #define WSAEISCONN (WSABASEERR+56)
136 #define WSAENOTCONN (WSABASEERR+57)
137 #define WSAESHUTDOWN (WSABASEERR+58)
138 #define WSAETOOMANYREFS (WSABASEERR+59)
139 #define WSAETIMEDOUT (WSABASEERR+60)
140 #define WSAECONNREFUSED (WSABASEERR+61)
141 #define WSAELOOP (WSABASEERR+62)
142 #define WSAENAMETOOLONG (WSABASEERR+63)
143 #define WSAEHOSTDOWN (WSABASEERR+64)
144 #define WSAEHOSTUNREACH (WSABASEERR+65)
145 #define WSAENOTEMPTY (WSABASEERR+66)
146 #define WSAEPROCLIM (WSABASEERR+67)
147 #define WSAEUSERS (WSABASEERR+68)
148 #define WSAEDQUOT (WSABASEERR+69)
149 #define WSAESTALE (WSABASEERR+70)
150 #define WSAEREMOTE (WSABASEERR+71)
153 * Extended Windows Sockets error constant definitions
155 #define WSASYSNOTREADY (WSABASEERR+91)
156 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
157 #define WSANOTINITIALISED (WSABASEERR+93)
160 * Error return codes from gethostbyname() and gethostbyaddr()
161 * (when using the resolver). Note that these errors are
162 * retrieved via WSAGetLastError() and must therefore follow
163 * the rules for avoiding clashes with error numbers from
164 * specific implementations or language run-time systems.
165 * For this reason the codes are based at WSABASEERR+1001.
166 * Note also that [WSA]NO_ADDRESS is defined only for
167 * compatibility purposes.
170 /* #define h_errno WSAGetLastError() */
172 /* Authoritative Answer: Host not found */
173 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
175 /* Non-Authoritative: Host not found, or SERVERFAIL */
176 #define WSATRY_AGAIN (WSABASEERR+1002)
178 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
179 #define WSANO_RECOVERY (WSABASEERR+1003)
181 /* Valid name, no data record of requested type */
182 #define WSANO_DATA (WSABASEERR+1004)
184 /* no address, look for MX record */
185 #define WSANO_ADDRESS WSANO_DATA
187 /* Socket function prototypes */
189 #ifdef __cplusplus
190 extern "C" {
191 #endif
193 /* Microsoft Windows Extension function prototypes */
195 INT PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
197 INT PASCAL FAR WSACleanup(void);
199 void PASCAL FAR WSASetLastError(INT iError);
201 INT PASCAL FAR WSAGetLastError(void);
203 BOOL PASCAL FAR WSAIsBlocking(void);
205 INT PASCAL FAR WSAUnhookBlockingHook(void);
207 FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc);
209 INT PASCAL FAR WSACancelBlockingCall(void);
211 HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
212 const char FAR *name,
213 const char FAR *proto,
214 char FAR *buf, INT buflen);
216 HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, INT port,
217 const char FAR *proto, char FAR *buf,
218 INT buflen);
220 HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
221 const char FAR *name, char FAR *buf,
222 INT buflen);
224 HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
225 INT number, char FAR *buf,
226 INT buflen);
228 HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
229 const char FAR *name, char FAR *buf,
230 INT buflen);
232 HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
233 const char FAR *addr, INT len, INT type,
234 char FAR *buf, INT buflen);
236 INT PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
238 INT PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
240 #ifdef __cplusplus
242 #endif
244 /* Microsoft Windows Extended data types */
245 typedef struct sockaddr SOCKADDR;
246 typedef struct sockaddr *PSOCKADDR;
247 typedef struct sockaddr FAR *LPSOCKADDR;
249 typedef struct sockaddr_in SOCKADDR_IN;
250 typedef struct sockaddr_in *PSOCKADDR_IN;
251 typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
253 typedef struct linger LINGER;
254 typedef struct linger *PLINGER;
255 typedef struct linger FAR *LPLINGER;
257 typedef struct in_addr IN_ADDR;
258 typedef struct in_addr *PIN_ADDR;
259 typedef struct in_addr FAR *LPIN_ADDR;
261 typedef struct fd_set FD_SET;
262 typedef struct fd_set *PFD_SET;
263 typedef struct fd_set FAR *LPFD_SET;
265 typedef struct hostent HOSTENT;
266 typedef struct hostent *PHOSTENT;
267 typedef struct hostent FAR *LPHOSTENT;
269 typedef struct servent SERVENT;
270 typedef struct servent *PSERVENT;
271 typedef struct servent FAR *LPSERVENT;
273 typedef struct protoent PROTOENT;
274 typedef struct protoent *PPROTOENT;
275 typedef struct protoent FAR *LPPROTOENT;
277 typedef struct timeval TIMEVAL;
278 typedef struct timeval *PTIMEVAL;
279 typedef struct timeval FAR *LPTIMEVAL;
282 * Windows message parameter composition and decomposition
283 * macros.
285 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
286 * when constructing the response to a WSAAsyncGetXByY() routine.
288 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
290 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
291 * when constructing the response to WSAAsyncSelect().
293 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
295 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
296 * to extract the buffer length from the lParam in the response
297 * to a WSAGetXByY().
299 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
301 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
302 * to extract the error code from the lParam in the response
303 * to a WSAGetXByY().
305 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
307 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
308 * to extract the event code from the lParam in the response
309 * to a WSAAsyncSelect().
311 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
313 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
314 * to extract the error code from the lParam in the response
315 * to a WSAAsyncSelect().
317 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
319 #endif /* _WINSOCKAPI_ */