1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
11 #include <sys/types.h>
15 #include <netinet/in.h>
16 #include <sys/socket.h>
19 * The new type to be used in all
20 * instances which refer to sockets.
24 extern int PASCAL FAR
__WSAFDIsSet(SOCKET
, fd_set FAR
*);
27 * Internet address (old style... should be updated)
29 #define s_addr S_un.S_addr /* can be used for most tcp & ip code */
30 #define s_host S_un.S_un_b.s_b2 /* host on imp */
31 #define s_net S_un.S_un_b.s_b1 /* network */
32 #define s_imp S_un.S_un_w.s_w2 /* imp */
33 #define s_impno S_un.S_un_b.s_b4 /* imp # */
34 #define s_lh S_un.S_un_b.s_b3 /* logical host */
36 #define WSADESCRIPTION_LEN 256
37 #define WSASYS_STATUS_LEN 128
39 typedef struct WSAData
{
42 char szDescription
[WSADESCRIPTION_LEN
+1];
43 char szSystemStatus
[WSASYS_STATUS_LEN
+1];
44 unsigned short iMaxSockets
;
45 unsigned short iMaxUdpDg
;
46 char FAR
* lpVendorInfo
;
49 typedef WSADATA FAR
*LPWSADATA
;
52 * This is used instead of -1, since the
53 * SOCKET type is unsigned.
55 #define INVALID_SOCKET (SOCKET)(~0)
56 #define SOCKET_ERROR (-1)
59 * Option flags per-socket.
62 #define SO_DONTLINGER (u_int)(~SO_LINGER)
65 #ifndef _SYS_SOCKET_H_
68 * Structure used by kernel to pass protocol
69 * information in raw sockets.
72 u_short sp_family
; /* address family */
73 u_short sp_protocol
; /* protocol */
79 * Maximum queue length specifiable by listen.
82 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
83 #define MSG_MAXIOVLEN 16
86 * Define constant based on rfc883, used by gethostbyxxxx() calls.
88 #define MAXGETHOSTSTRUCT 1024
91 * Define flags to be used with the WSAAsyncSelect() call.
96 #define FD_ACCEPT 0x08
97 #define FD_CONNECT 0x10
101 * All Windows Sockets error constants are biased by WSABASEERR from
104 #define WSABASEERR 10000
106 * Windows Sockets definitions of regular Microsoft C error constants
108 #define WSAEINTR (WSABASEERR+4)
109 #define WSAEBADF (WSABASEERR+9)
110 #define WSAEACCES (WSABASEERR+13)
111 #define WSAEFAULT (WSABASEERR+14)
112 #define WSAEINVAL (WSABASEERR+22)
113 #define WSAEMFILE (WSABASEERR+24)
116 * Windows Sockets definitions of regular Berkeley error constants
118 #define WSAEWOULDBLOCK (WSABASEERR+35)
119 #define WSAEINPROGRESS (WSABASEERR+36)
120 #define WSAEALREADY (WSABASEERR+37)
121 #define WSAENOTSOCK (WSABASEERR+38)
122 #define WSAEDESTADDRREQ (WSABASEERR+39)
123 #define WSAEMSGSIZE (WSABASEERR+40)
124 #define WSAEPROTOTYPE (WSABASEERR+41)
125 #define WSAENOPROTOOPT (WSABASEERR+42)
126 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
127 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
128 #define WSAEOPNOTSUPP (WSABASEERR+45)
129 #define WSAEPFNOSUPPORT (WSABASEERR+46)
130 #define WSAEAFNOSUPPORT (WSABASEERR+47)
131 #define WSAEADDRINUSE (WSABASEERR+48)
132 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
133 #define WSAENETDOWN (WSABASEERR+50)
134 #define WSAENETUNREACH (WSABASEERR+51)
135 #define WSAENETRESET (WSABASEERR+52)
136 #define WSAECONNABORTED (WSABASEERR+53)
137 #define WSAECONNRESET (WSABASEERR+54)
138 #define WSAENOBUFS (WSABASEERR+55)
139 #define WSAEISCONN (WSABASEERR+56)
140 #define WSAENOTCONN (WSABASEERR+57)
141 #define WSAESHUTDOWN (WSABASEERR+58)
142 #define WSAETOOMANYREFS (WSABASEERR+59)
143 #define WSAETIMEDOUT (WSABASEERR+60)
144 #define WSAECONNREFUSED (WSABASEERR+61)
145 #define WSAELOOP (WSABASEERR+62)
146 #define WSAENAMETOOLONG (WSABASEERR+63)
147 #define WSAEHOSTDOWN (WSABASEERR+64)
148 #define WSAEHOSTUNREACH (WSABASEERR+65)
149 #define WSAENOTEMPTY (WSABASEERR+66)
150 #define WSAEPROCLIM (WSABASEERR+67)
151 #define WSAEUSERS (WSABASEERR+68)
152 #define WSAEDQUOT (WSABASEERR+69)
153 #define WSAESTALE (WSABASEERR+70)
154 #define WSAEREMOTE (WSABASEERR+71)
157 * Extended Windows Sockets error constant definitions
159 #define WSASYSNOTREADY (WSABASEERR+91)
160 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
161 #define WSANOTINITIALISED (WSABASEERR+93)
164 * Error return codes from gethostbyname() and gethostbyaddr()
165 * (when using the resolver). Note that these errors are
166 * retrieved via WSAGetLastError() and must therefore follow
167 * the rules for avoiding clashes with error numbers from
168 * specific implementations or language run-time systems.
169 * For this reason the codes are based at WSABASEERR+1001.
170 * Note also that [WSA]NO_ADDRESS is defined only for
171 * compatibility purposes.
174 #define h_errno WSAGetLastError()
176 /* Authoritative Answer: Host not found */
177 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
179 /* Non-Authoritative: Host not found, or SERVERFAIL */
180 #define WSATRY_AGAIN (WSABASEERR+1002)
182 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
183 #define WSANO_RECOVERY (WSABASEERR+1003)
185 /* Valid name, no data record of requested type */
186 #define WSANO_DATA (WSABASEERR+1004)
188 /* no address, look for MX record */
189 #define WSANO_ADDRESS WSANO_DATA
192 * Windows Sockets errors redefined as regular Berkeley error constants
196 #define EWOULDBLOCK WSAEWOULDBLOCK
197 #define EINPROGRESS WSAEINPROGRESS
198 #define EALREADY WSAEALREADY
199 #define ENOTSOCK WSAENOTSOCK
200 #define EDESTADDRREQ WSAEDESTADDRREQ
201 #define EMSGSIZE WSAEMSGSIZE
202 #define EPROTOTYPE WSAEPROTOTYPE
203 #define ENOPROTOOPT WSAENOPROTOOPT
204 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
205 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
206 #define EOPNOTSUPP WSAEOPNOTSUPP
207 #define EPFNOSUPPORT WSAEPFNOSUPPORT
208 #define EAFNOSUPPORT WSAEAFNOSUPPORT
209 #define EADDRINUSE WSAEADDRINUSE
210 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
211 #define ENETDOWN WSAENETDOWN
212 #define ENETUNREACH WSAENETUNREACH
213 #define ENETRESET WSAENETRESET
214 #define ECONNABORTED WSAECONNABORTED
215 #define ECONNRESET WSAECONNRESET
216 #define ENOBUFS WSAENOBUFS
217 #define EISCONN WSAEISCONN
218 #define ENOTCONN WSAENOTCONN
219 #define ESHUTDOWN WSAESHUTDOWN
220 #define ETOOMANYREFS WSAETOOMANYREFS
221 #define ETIMEDOUT WSAETIMEDOUT
222 #define ECONNREFUSED WSAECONNREFUSED
223 #define ELOOP WSAELOOP
224 #define ENAMETOOLONG WSAENAMETOOLONG
225 #define EHOSTDOWN WSAEHOSTDOWN
226 #define EHOSTUNREACH WSAEHOSTUNREACH
227 #define ENOTEMPTY WSAENOTEMPTY
228 #define EPROCLIM WSAEPROCLIM
229 #define EUSERS WSAEUSERS
230 #define EDQUOT WSAEDQUOT
231 #define ESTALE WSAESTALE
232 #define EREMOTE WSAEREMOTE
236 /* Socket function prototypes */
242 /* Microsoft Windows Extension function prototypes */
244 int PASCAL FAR
WSAStartup(WORD wVersionRequired
, LPWSADATA lpWSAData
);
246 int PASCAL FAR
WSACleanup(void);
248 void PASCAL FAR
WSASetLastError(int iError
);
250 int PASCAL FAR
WSAGetLastError(void);
252 BOOL PASCAL FAR
WSAIsBlocking(void);
254 int PASCAL FAR
WSAUnhookBlockingHook(void);
256 FARPROC PASCAL FAR
WSASetBlockingHook(FARPROC lpBlockFunc
);
258 int PASCAL FAR
WSACancelBlockingCall(void);
260 HANDLE PASCAL FAR
WSAAsyncGetServByName(HWND hWnd
, u_int wMsg
,
261 const char FAR
* name
,
262 const char FAR
* proto
,
263 char FAR
* buf
, int buflen
);
265 HANDLE PASCAL FAR
WSAAsyncGetServByPort(HWND hWnd
, u_int wMsg
, int port
,
266 const char FAR
* proto
, char FAR
* buf
,
269 HANDLE PASCAL FAR
WSAAsyncGetProtoByName(HWND hWnd
, u_int wMsg
,
270 const char FAR
* name
, char FAR
* buf
,
273 HANDLE PASCAL FAR
WSAAsyncGetProtoByNumber(HWND hWnd
, u_int wMsg
,
274 int number
, char FAR
* buf
,
277 HANDLE PASCAL FAR
WSAAsyncGetHostByName(HWND hWnd
, u_int wMsg
,
278 const char FAR
* name
, char FAR
* buf
,
281 HANDLE PASCAL FAR
WSAAsyncGetHostByAddr(HWND hWnd
, u_int wMsg
,
282 const char FAR
* addr
, int len
, int type
,
283 const char FAR
* buf
, int buflen
);
285 int PASCAL FAR
WSACancelAsyncRequest(HANDLE hAsyncTaskHandle
);
287 int PASCAL FAR
WSAAsyncSelect(SOCKET s
, HWND hWnd
, u_int wMsg
,
294 /* Microsoft Windows Extended data types */
295 typedef struct sockaddr SOCKADDR
;
296 typedef struct sockaddr
*PSOCKADDR
;
297 typedef struct sockaddr FAR
*LPSOCKADDR
;
299 typedef struct sockaddr_in SOCKADDR_IN
;
300 typedef struct sockaddr_in
*PSOCKADDR_IN
;
301 typedef struct sockaddr_in FAR
*LPSOCKADDR_IN
;
303 typedef struct linger LINGER
;
304 typedef struct linger
*PLINGER
;
305 typedef struct linger FAR
*LPLINGER
;
307 typedef struct in_addr IN_ADDR
;
308 typedef struct in_addr
*PIN_ADDR
;
309 typedef struct in_addr FAR
*LPIN_ADDR
;
311 typedef struct fd_set FD_SET
;
312 typedef struct fd_set
*PFD_SET
;
313 typedef struct fd_set FAR
*LPFD_SET
;
315 typedef struct hostent HOSTENT
;
316 typedef struct hostent
*PHOSTENT
;
317 typedef struct hostent FAR
*LPHOSTENT
;
319 typedef struct servent SERVENT
;
320 typedef struct servent
*PSERVENT
;
321 typedef struct servent FAR
*LPSERVENT
;
323 typedef struct protoent PROTOENT
;
324 typedef struct protoent
*PPROTOENT
;
325 typedef struct protoent FAR
*LPPROTOENT
;
327 typedef struct timeval TIMEVAL
;
328 typedef struct timeval
*PTIMEVAL
;
329 typedef struct timeval FAR
*LPTIMEVAL
;
332 * Windows message parameter composition and decomposition
335 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
336 * when constructing the response to a WSAAsyncGetXByY() routine.
338 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
340 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
341 * when constructing the response to WSAAsyncSelect().
343 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
345 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
346 * to extract the buffer length from the lParam in the response
349 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
351 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
352 * to extract the error code from the lParam in the response
355 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
357 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
358 * to extract the event code from the lParam in the response
359 * to a WSAAsyncSelect().
361 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
363 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
364 * to extract the error code from the lParam in the response
365 * to a WSAAsyncSelect().
367 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
369 #endif /* _WINSOCKAPI_ */