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

Last change on this file since 6502 was 6201, checked in by achimha, 24 years ago

implemented WSAEventSelect

File size: 8.6 KB
Line 
1/* $Id: wsock32.h,v 1.18 2001-07-07 14:29:41 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_MAX_EVENTS 10
55#define FD_READ 0x01
56#define FD_WRITE 0x02
57#define FD_OOB 0x04
58#define FD_ACCEPT 0x08
59#define FD_CONNECT 0x10
60#define FD_CLOSE 0x20
61// Winsock 2.0 only
62#define FD_QOS 0x40
63#define FD_GROUP_QOS 0x80
64#define FD_ROUTING_INTERFACE_CHANGE 0x100
65#define FD_ADDRESS_LIST_CHANGE 0x200
66
67#define SOCKET_ERROR -1
68#define NO_ERROR 0
69
70#define WSABASEERR 10000
71
72#define WSAEINTR (WSABASEERR+4)
73#define WSAEBADF (WSABASEERR+9)
74#define WSAEACCES (WSABASEERR+13)
75#define WSAEFAULT (WSABASEERR+14)
76#define WSAEINVAL (WSABASEERR+22)
77#define WSAEMFILE (WSABASEERR+24)
78
79#define WSAEWOULDBLOCK (WSABASEERR+35)
80#define WSAEINPROGRESS (WSABASEERR+36)
81#define WSAEALREADY (WSABASEERR+37)
82#define WSAENOTSOCK (WSABASEERR+38)
83#define WSAEDESTADDRREQ (WSABASEERR+39)
84#define WSAEMSGSIZE (WSABASEERR+40)
85#define WSAEPROTOTYPE (WSABASEERR+41)
86#define WSAENOPROTOOPT (WSABASEERR+42)
87#define WSAEPROTONOSUPPORT (WSABASEERR+43)
88#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
89#define WSAEOPNOTSUPP (WSABASEERR+45)
90#define WSAEPFNOSUPPORT (WSABASEERR+46)
91#define WSAEAFNOSUPPORT (WSABASEERR+47)
92#define WSAEADDRINUSE (WSABASEERR+48)
93#define WSAEADDRNOTAVAIL (WSABASEERR+49)
94#define WSAENETDOWN (WSABASEERR+50)
95#define WSAENETUNREACH (WSABASEERR+51)
96#define WSAENETRESET (WSABASEERR+52)
97#define WSAECONNABORTED (WSABASEERR+53)
98#define WSAECONNRESET (WSABASEERR+54)
99#define WSAENOBUFS (WSABASEERR+55)
100#define WSAEISCONN (WSABASEERR+56)
101#define WSAENOTCONN (WSABASEERR+57)
102#define WSAESHUTDOWN (WSABASEERR+58)
103#define WSAETOOMANYREFS (WSABASEERR+59)
104#define WSAETIMEDOUT (WSABASEERR+60)
105#define WSAECONNREFUSED (WSABASEERR+61)
106#define WSAELOOP (WSABASEERR+62)
107#define WSAENAMETOOLONG (WSABASEERR+63)
108#define WSAEHOSTDOWN (WSABASEERR+64)
109#define WSAEHOSTUNREACH (WSABASEERR+65)
110#define WSAENOTEMPTY (WSABASEERR+66)
111#define WSAEPROCLIM (WSABASEERR+67)
112#define WSAEUSERS (WSABASEERR+68)
113#define WSAEDQUOT (WSABASEERR+69)
114#define WSAESTALE (WSABASEERR+70)
115#define WSAEREMOTE (WSABASEERR+71)
116#define WSASYSNOTREADY (WSABASEERR+91)
117#define WSAVERNOTSUPPORTED (WSABASEERR+92)
118#define WSANOTINITIALISED (WSABASEERR+93)
119#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
120#define WSATRY_AGAIN (WSABASEERR+1002)
121#define WSANO_RECOVERY (WSABASEERR+1003)
122#define WSANO_DATA (WSABASEERR+1004)
123#define WSANO_ADDRESS WSANO_DATA
124
125typedef u_int SOCKET;
126
127#define FD_SETSIZE 64
128
129#pragma pack(1)
130
131#define WSADESCRIPTION_LEN 256
132#define WSASYS_STATUS_LEN 128
133
134typedef struct WSAData {
135 USHORT wVersion;
136 USHORT wHighVersion;
137 char szDescription[WSADESCRIPTION_LEN+1];
138 char szSystemStatus[WSASYS_STATUS_LEN+1];
139 unsigned short iMaxSockets;
140 unsigned short iMaxUdpDg;
141 char * lpVendorInfo;
142} WSADATA;
143typedef WSADATA *PWSADATA;
144typedef WSADATA *LPWSADATA;
145
146typedef struct ws_fd_set {
147 u_int fd_count;
148 SOCKET fd_array[FD_SETSIZE];
149} _ws_fd_set;
150
151/*
152 * Structure used for manipulating linger option.
153 */
154typedef struct ws_linger {
155 u_short l_onoff; /* option on/off */
156 u_short l_linger; /* linger time */
157} _ws_linger;
158
159/*
160 * Structures returned by network data base library, taken from the
161 * BSD file netdb.h. All addresses are supplied in host order, and
162 * returned in network order (suitable for use in system calls).
163 */
164
165typedef struct ws_hostent
166{
167 char * h_name; /* official name of host */
168 char ** h_aliases; /* alias list */
169 INT16 h_addrtype; /* host address type */
170 INT16 h_length; /* length of address */
171 char ** h_addr_list; /* list of addresses from name server */
172} _ws_hostent;
173
174typedef struct ws_protoent
175{
176 char * p_name; /* official protocol name */
177 char ** p_aliases; /* alias list */
178 INT16 p_proto; /* protocol # */
179} _ws_protoent;
180
181typedef struct ws_servent
182{
183 char * s_name; /* official service name */
184 char ** s_aliases; /* alias list */
185 INT16 s_port; /* port # */
186 char * s_proto; /* protocol to use */
187} _ws_servent;
188
189typedef struct ws_netent
190{
191 char * n_name; /* official name of net */
192 char ** n_aliases; /* alias list */
193 INT16 n_addrtype; /* net address type */
194 INT n_net; /* network # */
195} _ws_netent;
196
197#pragma pack()
198
199#define WS_MAX_SOCKETS_PER_PROCESS 2048
200#define WS_MAX_UDP_DATAGRAM 32767
201
202#define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
203#define WSI_BLOCKINGHOOK 0x00000002 /* 32-bit callback */
204
205typedef struct _WSINFO
206{
207 DWORD dwThisThread;
208 struct _WSINFO *lpNextIData;
209
210 unsigned flags;
211 INT16 num_startup; /* reference counter */
212 INT16 num_async_rq;
213 INT16 last_free; /* entry in the socket table */
214 USHORT buflen;
215 char* buffer; /* allocated from char * heap */
216 struct ws_hostent *he;
217 int helen;
218 struct ws_servent *se;
219 int selen;
220 struct ws_protoent *pe;
221 int pelen;
222 char* dbuffer; /* buffer for dummies (32 bytes) */
223
224 DWORD blocking_hook;
225} WSINFO, *LPWSINFO;
226
227void WIN32API WSASetLastError(int iError);
228int WIN32API WSAGetLastError(void);
229int WIN32API WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
230BOOL WIN32API WSAIsBlocking(void);
231
232extern BOOL fWSAInitialized;
233
234UINT wsaErrno();
235UINT wsaHerrno();
236
237#define CURRENT_THREAD -1
238void WSASetBlocking(BOOL fBlock, HANDLE tid = CURRENT_THREAD);
239
240void WINSOCK_DeleteIData(void);
241BOOL WINSOCK_CreateIData(void);
242LPWSINFO WINSOCK_GetIData(HANDLE tid = CURRENT_THREAD);
243
244typedef HANDLE WSAEVENT;
245
246// modes for the async select worker
247#define WSA_SELECT_HWND 1
248#define WSA_SELECT_HEVENT 2
249// async select worker routine
250int WSAAsyncSelectWorker(SOCKET s, int mode, int notifyHandle, int notifyData, long lEventMask);
251
252typedef struct _WSANETWORKEVENTS
253{
254 long lNetworkEvents;
255 int iErrorCode[FD_MAX_EVENTS];
256} WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
257int WSAEnumNetworkEventsWorker(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lpEvent);
258
259#endif /* _WINSOCK32CONST_ */
260
261
Note: See TracBrowser for help on using the repository browser.