1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
10 #include <sys/types.h>
14 #include <netinet/in.h>
15 #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_
67 #ifndef _NET_TRANSPORT_SOCKET_H
70 * Structure used by kernel to pass protocol
71 * information in raw sockets.
74 u_short sp_family
; /* address family */
75 u_short sp_protocol
; /* protocol */
83 * Maximum queue length specifiable by listen.
91 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
93 #define MSG_MAXIOVLEN 16
96 * Define constant based on rfc883, used by gethostbyxxxx() calls.
98 #define MAXGETHOSTSTRUCT 1024
101 * Define flags to be used with the WSAAsyncSelect() call.
104 #define FD_WRITE 0x02
106 #define FD_ACCEPT 0x08
107 #define FD_CONNECT 0x10
108 #define FD_CLOSE 0x20
111 * All Windows Sockets error constants are biased by WSABASEERR from
114 #define WSABASEERR 10000
116 * Windows Sockets definitions of regular Microsoft C error constants
118 #define WSAEINTR (WSABASEERR+4)
119 #define WSAEBADF (WSABASEERR+9)
120 #define WSAEACCES (WSABASEERR+13)
121 #define WSAEFAULT (WSABASEERR+14)
122 #define WSAEINVAL (WSABASEERR+22)
123 #define WSAEMFILE (WSABASEERR+24)
126 * Windows Sockets definitions of regular Berkeley error constants
128 #define WSAEWOULDBLOCK (WSABASEERR+35)
129 #define WSAEINPROGRESS (WSABASEERR+36)
130 #define WSAEALREADY (WSABASEERR+37)
131 #define WSAENOTSOCK (WSABASEERR+38)
132 #define WSAEDESTADDRREQ (WSABASEERR+39)
133 #define WSAEMSGSIZE (WSABASEERR+40)
134 #define WSAEPROTOTYPE (WSABASEERR+41)
135 #define WSAENOPROTOOPT (WSABASEERR+42)
136 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
137 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
138 #define WSAEOPNOTSUPP (WSABASEERR+45)
139 #define WSAEPFNOSUPPORT (WSABASEERR+46)
140 #define WSAEAFNOSUPPORT (WSABASEERR+47)
141 #define WSAEADDRINUSE (WSABASEERR+48)
142 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
143 #define WSAENETDOWN (WSABASEERR+50)
144 #define WSAENETUNREACH (WSABASEERR+51)
145 #define WSAENETRESET (WSABASEERR+52)
146 #define WSAECONNABORTED (WSABASEERR+53)
147 #define WSAECONNRESET (WSABASEERR+54)
148 #define WSAENOBUFS (WSABASEERR+55)
149 #define WSAEISCONN (WSABASEERR+56)
150 #define WSAENOTCONN (WSABASEERR+57)
151 #define WSAESHUTDOWN (WSABASEERR+58)
152 #define WSAETOOMANYREFS (WSABASEERR+59)
153 #define WSAETIMEDOUT (WSABASEERR+60)
154 #define WSAECONNREFUSED (WSABASEERR+61)
155 #define WSAELOOP (WSABASEERR+62)
156 #define WSAENAMETOOLONG (WSABASEERR+63)
157 #define WSAEHOSTDOWN (WSABASEERR+64)
158 #define WSAEHOSTUNREACH (WSABASEERR+65)
159 #define WSAENOTEMPTY (WSABASEERR+66)
160 #define WSAEPROCLIM (WSABASEERR+67)
161 #define WSAEUSERS (WSABASEERR+68)
162 #define WSAEDQUOT (WSABASEERR+69)
163 #define WSAESTALE (WSABASEERR+70)
164 #define WSAEREMOTE (WSABASEERR+71)
167 * Extended Windows Sockets error constant definitions
169 #define WSASYSNOTREADY (WSABASEERR+91)
170 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
171 #define WSANOTINITIALISED (WSABASEERR+93)
174 * Error return codes from gethostbyname() and gethostbyaddr()
175 * (when using the resolver). Note that these errors are
176 * retrieved via WSAGetLastError() and must therefore follow
177 * the rules for avoiding clashes with error numbers from
178 * specific implementations or language run-time systems.
179 * For this reason the codes are based at WSABASEERR+1001.
180 * Note also that [WSA]NO_ADDRESS is defined only for
181 * compatibility purposes.
184 /* #define h_errno WSAGetLastError() */
186 /* Authoritative Answer: Host not found */
187 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
189 /* Non-Authoritative: Host not found, or SERVERFAIL */
190 #define WSATRY_AGAIN (WSABASEERR+1002)
192 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
193 #define WSANO_RECOVERY (WSABASEERR+1003)
195 /* Valid name, no data record of requested type */
196 #define WSANO_DATA (WSABASEERR+1004)
198 /* no address, look for MX record */
199 #define WSANO_ADDRESS WSANO_DATA
201 /* Socket function prototypes */
207 /* Microsoft Windows Extension function prototypes */
209 INT PASCAL FAR
WSAStartup(WORD wVersionRequired
, LPWSADATA lpWSAData
);
211 INT PASCAL FAR
WSACleanup(void);
213 void PASCAL FAR
WSASetLastError(INT iError
);
215 INT PASCAL FAR
WSAGetLastError(void);
217 BOOL PASCAL FAR
WSAIsBlocking(void);
219 INT PASCAL FAR
WSAUnhookBlockingHook(void);
221 FARPROC PASCAL FAR
WSASetBlockingHook(FARPROC lpBlockFunc
);
223 INT PASCAL FAR
WSACancelBlockingCall(void);
225 HANDLE PASCAL FAR
WSAAsyncGetServByName(HWND hWnd
, u_int wMsg
,
226 const char FAR
*name
,
227 const char FAR
*proto
,
228 char FAR
*buf
, INT buflen
);
230 HANDLE PASCAL FAR
WSAAsyncGetServByPort(HWND hWnd
, u_int wMsg
, INT port
,
231 const char FAR
*proto
, char FAR
*buf
,
234 HANDLE PASCAL FAR
WSAAsyncGetProtoByName(HWND hWnd
, u_int wMsg
,
235 const char FAR
*name
, char FAR
*buf
,
238 HANDLE PASCAL FAR
WSAAsyncGetProtoByNumber(HWND hWnd
, u_int wMsg
,
239 INT number
, char FAR
*buf
,
242 HANDLE PASCAL FAR
WSAAsyncGetHostByName(HWND hWnd
, u_int wMsg
,
243 const char FAR
*name
, char FAR
*buf
,
246 HANDLE PASCAL FAR
WSAAsyncGetHostByAddr(HWND hWnd
, u_int wMsg
,
247 const char FAR
*addr
, INT len
, INT type
,
248 char FAR
*buf
, INT buflen
);
250 INT PASCAL FAR
WSACancelAsyncRequest(HANDLE hAsyncTaskHandle
);
252 INT PASCAL FAR
WSAAsyncSelect(SOCKET s
, HWND hWnd
, u_int wMsg
, long lEvent
);
258 /* Microsoft Windows Extended data types */
259 typedef struct sockaddr SOCKADDR
;
260 typedef struct sockaddr
*PSOCKADDR
;
261 typedef struct sockaddr FAR
*LPSOCKADDR
;
263 typedef struct sockaddr_in SOCKADDR_IN
;
264 typedef struct sockaddr_in
*PSOCKADDR_IN
;
265 typedef struct sockaddr_in FAR
*LPSOCKADDR_IN
;
267 typedef struct linger LINGER
;
268 typedef struct linger
*PLINGER
;
269 typedef struct linger FAR
*LPLINGER
;
271 typedef struct in_addr IN_ADDR
;
272 typedef struct in_addr
*PIN_ADDR
;
273 typedef struct in_addr FAR
*LPIN_ADDR
;
275 typedef struct fd_set FD_SET
;
276 typedef struct fd_set
*PFD_SET
;
277 typedef struct fd_set FAR
*LPFD_SET
;
279 typedef struct hostent HOSTENT
;
280 typedef struct hostent
*PHOSTENT
;
281 typedef struct hostent FAR
*LPHOSTENT
;
283 typedef struct servent SERVENT
;
284 typedef struct servent
*PSERVENT
;
285 typedef struct servent FAR
*LPSERVENT
;
287 typedef struct protoent PROTOENT
;
288 typedef struct protoent
*PPROTOENT
;
289 typedef struct protoent FAR
*LPPROTOENT
;
291 typedef struct timeval TIMEVAL
;
292 typedef struct timeval
*PTIMEVAL
;
293 typedef struct timeval FAR
*LPTIMEVAL
;
296 * Windows message parameter composition and decomposition
299 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
300 * when constructing the response to a WSAAsyncGetXByY() routine.
302 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
304 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
305 * when constructing the response to WSAAsyncSelect().
307 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
309 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
310 * to extract the buffer length from the lParam in the response
313 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
315 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
316 * to extract the error code from the lParam in the response
319 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
321 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
322 * to extract the event code from the lParam in the response
323 * to a WSAAsyncSelect().
325 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
327 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
328 * to extract the error code from the lParam in the response
329 * to a WSAAsyncSelect().
331 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
333 #endif /* _WINSOCKAPI_ */