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.
84 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
86 #define MSG_MAXIOVLEN 16
89 * Define constant based on rfc883, used by gethostbyxxxx() calls.
91 #define MAXGETHOSTSTRUCT 1024
94 * Define flags to be used with the WSAAsyncSelect() call.
99 #define FD_ACCEPT 0x08
100 #define FD_CONNECT 0x10
101 #define FD_CLOSE 0x20
104 * All Windows Sockets error constants are biased by WSABASEERR from
107 #define WSABASEERR 10000
109 * Windows Sockets definitions of regular Microsoft C error constants
111 #define WSAEINTR (WSABASEERR+4)
112 #define WSAEBADF (WSABASEERR+9)
113 #define WSAEACCES (WSABASEERR+13)
114 #define WSAEFAULT (WSABASEERR+14)
115 #define WSAEINVAL (WSABASEERR+22)
116 #define WSAEMFILE (WSABASEERR+24)
119 * Windows Sockets definitions of regular Berkeley error constants
121 #define WSAEWOULDBLOCK (WSABASEERR+35)
122 #define WSAEINPROGRESS (WSABASEERR+36)
123 #define WSAEALREADY (WSABASEERR+37)
124 #define WSAENOTSOCK (WSABASEERR+38)
125 #define WSAEDESTADDRREQ (WSABASEERR+39)
126 #define WSAEMSGSIZE (WSABASEERR+40)
127 #define WSAEPROTOTYPE (WSABASEERR+41)
128 #define WSAENOPROTOOPT (WSABASEERR+42)
129 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
130 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
131 #define WSAEOPNOTSUPP (WSABASEERR+45)
132 #define WSAEPFNOSUPPORT (WSABASEERR+46)
133 #define WSAEAFNOSUPPORT (WSABASEERR+47)
134 #define WSAEADDRINUSE (WSABASEERR+48)
135 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
136 #define WSAENETDOWN (WSABASEERR+50)
137 #define WSAENETUNREACH (WSABASEERR+51)
138 #define WSAENETRESET (WSABASEERR+52)
139 #define WSAECONNABORTED (WSABASEERR+53)
140 #define WSAECONNRESET (WSABASEERR+54)
141 #define WSAENOBUFS (WSABASEERR+55)
142 #define WSAEISCONN (WSABASEERR+56)
143 #define WSAENOTCONN (WSABASEERR+57)
144 #define WSAESHUTDOWN (WSABASEERR+58)
145 #define WSAETOOMANYREFS (WSABASEERR+59)
146 #define WSAETIMEDOUT (WSABASEERR+60)
147 #define WSAECONNREFUSED (WSABASEERR+61)
148 #define WSAELOOP (WSABASEERR+62)
149 #define WSAENAMETOOLONG (WSABASEERR+63)
150 #define WSAEHOSTDOWN (WSABASEERR+64)
151 #define WSAEHOSTUNREACH (WSABASEERR+65)
152 #define WSAENOTEMPTY (WSABASEERR+66)
153 #define WSAEPROCLIM (WSABASEERR+67)
154 #define WSAEUSERS (WSABASEERR+68)
155 #define WSAEDQUOT (WSABASEERR+69)
156 #define WSAESTALE (WSABASEERR+70)
157 #define WSAEREMOTE (WSABASEERR+71)
160 * Extended Windows Sockets error constant definitions
162 #define WSASYSNOTREADY (WSABASEERR+91)
163 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
164 #define WSANOTINITIALISED (WSABASEERR+93)
167 * Error return codes from gethostbyname() and gethostbyaddr()
168 * (when using the resolver). Note that these errors are
169 * retrieved via WSAGetLastError() and must therefore follow
170 * the rules for avoiding clashes with error numbers from
171 * specific implementations or language run-time systems.
172 * For this reason the codes are based at WSABASEERR+1001.
173 * Note also that [WSA]NO_ADDRESS is defined only for
174 * compatibility purposes.
177 #define h_errno WSAGetLastError()
179 /* Authoritative Answer: Host not found */
180 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
182 /* Non-Authoritative: Host not found, or SERVERFAIL */
183 #define WSATRY_AGAIN (WSABASEERR+1002)
185 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
186 #define WSANO_RECOVERY (WSABASEERR+1003)
188 /* Valid name, no data record of requested type */
189 #define WSANO_DATA (WSABASEERR+1004)
191 /* no address, look for MX record */
192 #define WSANO_ADDRESS WSANO_DATA
194 /* Socket function prototypes */
200 /* Microsoft Windows Extension function prototypes */
202 INT PASCAL FAR
WSAStartup(WORD wVersionRequired
, LPWSADATA lpWSAData
);
204 INT PASCAL FAR
WSACleanup(void);
206 void PASCAL FAR
WSASetLastError(INT iError
);
208 INT PASCAL FAR
WSAGetLastError(void);
210 BOOL PASCAL FAR
WSAIsBlocking(void);
212 INT PASCAL FAR
WSAUnhookBlockingHook(void);
214 FARPROC PASCAL FAR
WSASetBlockingHook(FARPROC lpBlockFunc
);
216 INT PASCAL FAR
WSACancelBlockingCall(void);
218 HANDLE PASCAL FAR
WSAAsyncGetServByName(HWND hWnd
, u_int wMsg
,
219 const char FAR
*name
,
220 const char FAR
*proto
,
221 char FAR
*buf
, INT buflen
);
223 HANDLE PASCAL FAR
WSAAsyncGetServByPort(HWND hWnd
, u_int wMsg
, INT port
,
224 const char FAR
*proto
, char FAR
*buf
,
227 HANDLE PASCAL FAR
WSAAsyncGetProtoByName(HWND hWnd
, u_int wMsg
,
228 const char FAR
*name
, char FAR
*buf
,
231 HANDLE PASCAL FAR
WSAAsyncGetProtoByNumber(HWND hWnd
, u_int wMsg
,
232 INT number
, char FAR
*buf
,
235 HANDLE PASCAL FAR
WSAAsyncGetHostByName(HWND hWnd
, u_int wMsg
,
236 const char FAR
*name
, char FAR
*buf
,
239 HANDLE PASCAL FAR
WSAAsyncGetHostByAddr(HWND hWnd
, u_int wMsg
,
240 const char FAR
*addr
, INT len
, INT type
,
241 char FAR
*buf
, INT buflen
);
243 INT PASCAL FAR
WSACancelAsyncRequest(HANDLE hAsyncTaskHandle
);
245 INT PASCAL FAR
WSAAsyncSelect(SOCKET s
, HWND hWnd
, u_int wMsg
, long lEvent
);
251 /* Microsoft Windows Extended data types */
252 typedef struct sockaddr SOCKADDR
;
253 typedef struct sockaddr
*PSOCKADDR
;
254 typedef struct sockaddr FAR
*LPSOCKADDR
;
256 typedef struct sockaddr_in SOCKADDR_IN
;
257 typedef struct sockaddr_in
*PSOCKADDR_IN
;
258 typedef struct sockaddr_in FAR
*LPSOCKADDR_IN
;
260 typedef struct linger LINGER
;
261 typedef struct linger
*PLINGER
;
262 typedef struct linger FAR
*LPLINGER
;
264 typedef struct in_addr IN_ADDR
;
265 typedef struct in_addr
*PIN_ADDR
;
266 typedef struct in_addr FAR
*LPIN_ADDR
;
268 typedef struct fd_set FD_SET
;
269 typedef struct fd_set
*PFD_SET
;
270 typedef struct fd_set FAR
*LPFD_SET
;
272 typedef struct hostent HOSTENT
;
273 typedef struct hostent
*PHOSTENT
;
274 typedef struct hostent FAR
*LPHOSTENT
;
276 typedef struct servent SERVENT
;
277 typedef struct servent
*PSERVENT
;
278 typedef struct servent FAR
*LPSERVENT
;
280 typedef struct protoent PROTOENT
;
281 typedef struct protoent
*PPROTOENT
;
282 typedef struct protoent FAR
*LPPROTOENT
;
284 typedef struct timeval TIMEVAL
;
285 typedef struct timeval
*PTIMEVAL
;
286 typedef struct timeval FAR
*LPTIMEVAL
;
289 * Windows message parameter composition and decomposition
292 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
293 * when constructing the response to a WSAAsyncGetXByY() routine.
295 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
297 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
298 * when constructing the response to WSAAsyncSelect().
300 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
302 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
303 * to extract the buffer length from the lParam in the response
306 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
308 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
309 * to extract the error code from the lParam in the response
312 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
314 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
315 * to extract the event code from the lParam in the response
316 * to a WSAAsyncSelect().
318 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
320 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
321 * to extract the error code from the lParam in the response
322 * to a WSAAsyncSelect().
324 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
326 #endif /* _WINSOCKAPI_ */