Release 961013
[wine.git] / include / winsock.h
blob95482297a3efea753b017e9a6f521efa18ce3d97
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"
20 * The new type to be used in all
21 * instances which refer to sockets.
23 typedef u_int SOCKET;
25 extern int __WSAFDIsSet(SOCKET, fd_set *);
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 *lpVendorInfo;
50 } WSADATA, *LPWSADATA;
53 * This is used instead of -1, since the
54 * SOCKET type is unsigned.
56 #define INVALID_SOCKET (SOCKET)(~0)
57 #define SOCKET_ERROR (-1)
60 * Option flags per-socket.
62 #ifndef SO_DONTLINGER
63 #define SO_DONTLINGER (u_int)(~SO_LINGER)
64 #endif
67 * Maximum queue length specifiable by listen.
69 #ifdef SOMAXCONN
70 #undef SOMAXCONN
71 #endif
72 #define SOMAXCONN 5
74 #ifndef MSG_DONTROUTE
75 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
76 #endif
77 #define MSG_MAXIOVLEN 16
80 * Define constant based on rfc883, used by gethostbyxxxx() calls.
82 #define MAXGETHOSTSTRUCT 1024
85 * Define flags to be used with the WSAAsyncSelect() call.
87 #define FD_READ 0x01
88 #define FD_WRITE 0x02
89 #define FD_OOB 0x04
90 #define FD_ACCEPT 0x08
91 #define FD_CONNECT 0x10
92 #define FD_CLOSE 0x20
95 * All Windows Sockets error constants are biased by WSABASEERR from
96 * the "normal"
98 #define WSABASEERR 10000
100 * Windows Sockets definitions of regular Microsoft C error constants
102 #define WSAEINTR (WSABASEERR+4)
103 #define WSAEBADF (WSABASEERR+9)
104 #define WSAEACCES (WSABASEERR+13)
105 #define WSAEFAULT (WSABASEERR+14)
106 #define WSAEINVAL (WSABASEERR+22)
107 #define WSAEMFILE (WSABASEERR+24)
110 * Windows Sockets definitions of regular Berkeley error constants
112 #define WSAEWOULDBLOCK (WSABASEERR+35)
113 #define WSAEINPROGRESS (WSABASEERR+36)
114 #define WSAEALREADY (WSABASEERR+37)
115 #define WSAENOTSOCK (WSABASEERR+38)
116 #define WSAEDESTADDRREQ (WSABASEERR+39)
117 #define WSAEMSGSIZE (WSABASEERR+40)
118 #define WSAEPROTOTYPE (WSABASEERR+41)
119 #define WSAENOPROTOOPT (WSABASEERR+42)
120 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
121 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
122 #define WSAEOPNOTSUPP (WSABASEERR+45)
123 #define WSAEPFNOSUPPORT (WSABASEERR+46)
124 #define WSAEAFNOSUPPORT (WSABASEERR+47)
125 #define WSAEADDRINUSE (WSABASEERR+48)
126 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
127 #define WSAENETDOWN (WSABASEERR+50)
128 #define WSAENETUNREACH (WSABASEERR+51)
129 #define WSAENETRESET (WSABASEERR+52)
130 #define WSAECONNABORTED (WSABASEERR+53)
131 #define WSAECONNRESET (WSABASEERR+54)
132 #define WSAENOBUFS (WSABASEERR+55)
133 #define WSAEISCONN (WSABASEERR+56)
134 #define WSAENOTCONN (WSABASEERR+57)
135 #define WSAESHUTDOWN (WSABASEERR+58)
136 #define WSAETOOMANYREFS (WSABASEERR+59)
137 #define WSAETIMEDOUT (WSABASEERR+60)
138 #define WSAECONNREFUSED (WSABASEERR+61)
139 #define WSAELOOP (WSABASEERR+62)
140 #define WSAENAMETOOLONG (WSABASEERR+63)
141 #define WSAEHOSTDOWN (WSABASEERR+64)
142 #define WSAEHOSTUNREACH (WSABASEERR+65)
143 #define WSAENOTEMPTY (WSABASEERR+66)
144 #define WSAEPROCLIM (WSABASEERR+67)
145 #define WSAEUSERS (WSABASEERR+68)
146 #define WSAEDQUOT (WSABASEERR+69)
147 #define WSAESTALE (WSABASEERR+70)
148 #define WSAEREMOTE (WSABASEERR+71)
151 * Extended Windows Sockets error constant definitions
153 #define WSASYSNOTREADY (WSABASEERR+91)
154 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
155 #define WSANOTINITIALISED (WSABASEERR+93)
158 * Error return codes from gethostbyname() and gethostbyaddr()
159 * (when using the resolver). Note that these errors are
160 * retrieved via WSAGetLastError() and must therefore follow
161 * the rules for avoiding clashes with error numbers from
162 * specific implementations or language run-time systems.
163 * For this reason the codes are based at WSABASEERR+1001.
164 * Note also that [WSA]NO_ADDRESS is defined only for
165 * compatibility purposes.
168 /* #define h_errno WSAGetLastError() */
170 /* Authoritative Answer: Host not found */
171 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
173 /* Non-Authoritative: Host not found, or SERVERFAIL */
174 #define WSATRY_AGAIN (WSABASEERR+1002)
176 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
177 #define WSANO_RECOVERY (WSABASEERR+1003)
179 /* Valid name, no data record of requested type */
180 #define WSANO_DATA (WSABASEERR+1004)
182 /* no address, look for MX record */
183 #define WSANO_ADDRESS WSANO_DATA
185 /* Socket function prototypes */
187 #ifdef __cplusplus
188 extern "C" {
189 #endif
191 /* Microsoft Windows Extension function prototypes */
193 INT WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
194 INT WSACleanup(void);
195 void WSASetLastError(INT iError);
196 INT WSAGetLastError(void);
197 BOOL WSAIsBlocking(void);
198 INT WSAUnhookBlockingHook(void);
199 FARPROC16 WSASetBlockingHook(FARPROC16 lpBlockFunc);
200 INT WSACancelBlockingCall(void);
201 HANDLE16 WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
202 LPCSTR name, LPCSTR proto,
203 LPSTR buf, INT buflen);
204 HANDLE16 WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, INT port,
205 LPCSTR proto, LPSTR buf, INT buflen);
206 HANDLE16 WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
207 LPCSTR name, LPSTR buf, INT buflen);
208 HANDLE16 WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
209 INT number, LPSTR buf, INT buflen);
210 HANDLE16 WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
211 LPCSTR name, LPSTR buf, INT buflen);
212 HANDLE16 WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, LPCSTR addr, INT len,
213 INT type, LPSTR buf, INT buflen);
214 INT WSACancelAsyncRequest(HANDLE16 hAsyncTaskHandle);
215 INT WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
217 #ifdef __cplusplus
219 #endif
221 /* Microsoft Windows Extended data types */
222 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
223 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
224 typedef struct linger LINGER, *PLINGER, *LPLINGER;
225 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
226 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
227 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
228 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
229 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
230 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
233 * Windows message parameter composition and decomposition
234 * macros.
236 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
237 * when constructing the response to a WSAAsyncGetXByY() routine.
239 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
241 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
242 * when constructing the response to WSAAsyncSelect().
244 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
246 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
247 * to extract the buffer length from the lParam in the response
248 * to a WSAGetXByY().
250 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
252 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
253 * to extract the error code from the lParam in the response
254 * to a WSAGetXByY().
256 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
258 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
259 * to extract the event code from the lParam in the response
260 * to a WSAAsyncSelect().
262 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
264 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
265 * to extract the error code from the lParam in the response
266 * to a WSAAsyncSelect().
268 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
270 #endif /* _WINSOCKAPI_ */