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

Last change on this file since 3195 was 3195, checked in by sandervl, 25 years ago

wsock32 rewrite (no pmwsock dependancy)

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