source: trunk/src/wsock32/wsock32.h@ 6199

Last change on this file since 6199 was 6196, checked in by achimha, 24 years ago

implemented WSAEventSelect

File size: 8.4 KB
Line 
1/* $Id: wsock32.h,v 1.17 2001-07-07 10:44:11 achimha Exp $ */
2
3/* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
4 * Unused/unneeded Microsoft declarations removed.
5 *
6 * This header file corresponds to version 1.1 of the Windows Sockets specification.
7 *
8 * This file includes parts which are Copyright (c) 1982-1986 Regents
9 * of the University of California. All rights reserved. The
10 * Berkeley Software License Agreement specifies the terms and
11 * conditions for redistribution.
12 *
13 */
14
15#ifndef _WINSOCK32CONST_
16#define _WINSOCK32CONST_
17
18#include <sys\socket.h>
19#include <sys\ioctl.h>
20#include <netdb.h>
21#include <netinet\in.h>
22#include <netinet\tcp.h>
23#include <nerrno.h>
24#include <sys\time.h>
25
26#include <odinwrap.h>
27
28/*
29 * Socket state bits.
30 */
31#define SS_NOFDREF 0x0001 /* no file table ref any more */
32#define SS_ISCONNECTED 0x0002 /* socket connected to a peer */
33#define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
34#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
35#define SS_CANTSENDMORE 0x0010 /* can't send more data to peer */
36#define SS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
37#define SS_RCVATMARK 0x0040 /* at mark on input */
38
39#define SS_NBIO 0x0100 /* non-blocking ops */
40#define SS_ASYNC 0x0200 /* async i/o notify */
41#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
42
43#define SS_INCOMP 0x0800 /* unaccepted, incomplete connection */
44#define SS_COMP 0x1000 /* unaccepted, complete connection */
45#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
46
47//socketopt options
48#define SO_DONTLINGER (u_int)(~SO_LINGER)
49
50#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
51
52// WSAAsyncSelect flags
53// also apply to Winsock 2.0 WSAEventSelect
54#define FD_READ 0x01
55#define FD_WRITE 0x02
56#define FD_OOB 0x04
57#define FD_ACCEPT 0x08
58#define FD_CONNECT 0x10
59#define FD_CLOSE 0x20
60// Winsock 2.0 only
61#define FD_QOS 0x40
62#define FD_GROUP_QOS 0x80
63#define FD_ROUTING_INTERFACE_CHANGE 0x100
64#define FD_ADDRESS_LIST_CHANGE 0x200
65
66#define SOCKET_ERROR -1
67#define NO_ERROR 0
68
69#define WSABASEERR 10000
70
71#define WSAEINTR (WSABASEERR+4)
72#define WSAEBADF (WSABASEERR+9)
73#define WSAEACCES (WSABASEERR+13)
74#define WSAEFAULT (WSABASEERR+14)
75#define WSAEINVAL (WSABASEERR+22)
76#define WSAEMFILE (WSABASEERR+24)
77
78#define WSAEWOULDBLOCK (WSABASEERR+35)
79#define WSAEINPROGRESS (WSABASEERR+36)
80#define WSAEALREADY (WSABASEERR+37)
81#define WSAENOTSOCK (WSABASEERR+38)
82#define WSAEDESTADDRREQ (WSABASEERR+39)
83#define WSAEMSGSIZE (WSABASEERR+40)
84#define WSAEPROTOTYPE (WSABASEERR+41)
85#define WSAENOPROTOOPT (WSABASEERR+42)
86#define WSAEPROTONOSUPPORT (WSABASEERR+43)
87#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
88#define WSAEOPNOTSUPP (WSABASEERR+45)
89#define WSAEPFNOSUPPORT (WSABASEERR+46)
90#define WSAEAFNOSUPPORT (WSABASEERR+47)
91#define WSAEADDRINUSE (WSABASEERR+48)
92#define WSAEADDRNOTAVAIL (WSABASEERR+49)
93#define WSAENETDOWN (WSABASEERR+50)
94#define WSAENETUNREACH (WSABASEERR+51)
95#define WSAENETRESET (WSABASEERR+52)
96#define WSAECONNABORTED (WSABASEERR+53)
97#define WSAECONNRESET (WSABASEERR+54)
98#define WSAENOBUFS (WSABASEERR+55)
99#define WSAEISCONN (WSABASEERR+56)
100#define WSAENOTCONN (WSABASEERR+57)
101#define WSAESHUTDOWN (WSABASEERR+58)
102#define WSAETOOMANYREFS (WSABASEERR+59)
103#define WSAETIMEDOUT (WSABASEERR+60)
104#define WSAECONNREFUSED (WSABASEERR+61)
105#define WSAELOOP (WSABASEERR+62)
106#define WSAENAMETOOLONG (WSABASEERR+63)
107#define WSAEHOSTDOWN (WSABASEERR+64)
108#define WSAEHOSTUNREACH (WSABASEERR+65)
109#define WSAENOTEMPTY (WSABASEERR+66)
110#define WSAEPROCLIM (WSABASEERR+67)
111#define WSAEUSERS (WSABASEERR+68)
112#define WSAEDQUOT (WSABASEERR+69)
113#define WSAESTALE (WSABASEERR+70)
114#define WSAEREMOTE (WSABASEERR+71)
115#define WSASYSNOTREADY (WSABASEERR+91)
116#define WSAVERNOTSUPPORTED (WSABASEERR+92)
117#define WSANOTINITIALISED (WSABASEERR+93)
118#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
119#define WSATRY_AGAIN (WSABASEERR+1002)
120#define WSANO_RECOVERY (WSABASEERR+1003)
121#define WSANO_DATA (WSABASEERR+1004)
122#define WSANO_ADDRESS WSANO_DATA
123
124typedef u_int SOCKET;
125
126#define FD_SETSIZE 64
127
128#pragma pack(1)
129
130#define WSADESCRIPTION_LEN 256
131#define WSASYS_STATUS_LEN 128
132
133typedef struct WSAData {
134 USHORT wVersion;
135 USHORT wHighVersion;
136 char szDescription[WSADESCRIPTION_LEN+1];
137 char szSystemStatus[WSASYS_STATUS_LEN+1];
138 unsigned short iMaxSockets;
139 unsigned short iMaxUdpDg;
140 char * lpVendorInfo;
141} WSADATA;
142typedef WSADATA *PWSADATA;
143typedef WSADATA *LPWSADATA;
144
145typedef struct ws_fd_set {
146 u_int fd_count;
147 SOCKET fd_array[FD_SETSIZE];
148} _ws_fd_set;
149
150/*
151 * Structure used for manipulating linger option.
152 */
153typedef struct ws_linger {
154 u_short l_onoff; /* option on/off */
155 u_short l_linger; /* linger time */
156} _ws_linger;
157
158/*
159 * Structures returned by network data base library, taken from the
160 * BSD file netdb.h. All addresses are supplied in host order, and
161 * returned in network order (suitable for use in system calls).
162 */
163
164typedef struct ws_hostent
165{
166 char * h_name; /* official name of host */
167 char ** h_aliases; /* alias list */
168 INT16 h_addrtype; /* host address type */
169 INT16 h_length; /* length of address */
170 char ** h_addr_list; /* list of addresses from name server */
171} _ws_hostent;
172
173typedef struct ws_protoent
174{
175 char * p_name; /* official protocol name */
176 char ** p_aliases; /* alias list */
177 INT16 p_proto; /* protocol # */
178} _ws_protoent;
179
180typedef struct ws_servent
181{
182 char * s_name; /* official service name */
183 char ** s_aliases; /* alias list */
184 INT16 s_port; /* port # */
185 char * s_proto; /* protocol to use */
186} _ws_servent;
187
188typedef struct ws_netent
189{
190 char * n_name; /* official name of net */
191 char ** n_aliases; /* alias list */
192 INT16 n_addrtype; /* net address type */
193 INT n_net; /* network # */
194} _ws_netent;
195
196#pragma pack()
197
198#define WS_MAX_SOCKETS_PER_PROCESS 2048
199#define WS_MAX_UDP_DATAGRAM 32767
200
201#define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
202#define WSI_BLOCKINGHOOK 0x00000002 /* 32-bit callback */
203
204typedef struct _WSINFO
205{
206 DWORD dwThisThread;
207 struct _WSINFO *lpNextIData;
208
209 unsigned flags;
210 INT16 num_startup; /* reference counter */
211 INT16 num_async_rq;
212 INT16 last_free; /* entry in the socket table */
213 USHORT buflen;
214 char* buffer; /* allocated from char * heap */
215 struct ws_hostent *he;
216 int helen;
217 struct ws_servent *se;
218 int selen;
219 struct ws_protoent *pe;
220 int pelen;
221 char* dbuffer; /* buffer for dummies (32 bytes) */
222
223 DWORD blocking_hook;
224} WSINFO, *LPWSINFO;
225
226void WIN32API WSASetLastError(int iError);
227int WIN32API WSAGetLastError(void);
228int WIN32API WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
229BOOL WIN32API WSAIsBlocking(void);
230
231extern BOOL fWSAInitialized;
232
233UINT wsaErrno();
234UINT wsaHerrno();
235
236#define CURRENT_THREAD -1
237void WSASetBlocking(BOOL fBlock, HANDLE tid = CURRENT_THREAD);
238
239void WINSOCK_DeleteIData(void);
240BOOL WINSOCK_CreateIData(void);
241LPWSINFO WINSOCK_GetIData(HANDLE tid = CURRENT_THREAD);
242
243typedef HANDLE WSAEVENT;
244
245// modes for the async select worker
246#define WSA_SELECT_HWND 1
247#define WSA_SELECT_HEVENT 2
248// async select worker routine
249int WSAAsyncSelectWorker(SOCKET s, int mode, int notifyHandle, int notifyData, long lEventMask);
250
251#endif /* _WINSOCK32CONST_ */
252
253
Note: See TracBrowser for help on using the repository browser.