118
|
1 /* Workable version of <sys/socket.h> based on winsock.h */
|
|
2
|
|
3 #ifndef _SOCKET_H_
|
|
4 #define _SOCKET_H_
|
|
5
|
|
6 /* defeat the multiple include protection */
|
|
7 #ifdef _WINSOCKAPI_
|
|
8 #undef _WINSOCKAPI_
|
|
9 #endif
|
|
10
|
|
11 /* avoid confusion with our version of select */
|
|
12 #ifdef select
|
|
13 #undef select
|
|
14 #define MUST_REDEF_SELECT
|
|
15 #endif
|
|
16
|
239
|
17 #if 0 /* What's wrong with winsock.h version ? - kkm */
|
118
|
18 /* avoid clashing with our version of FD_SET if already defined */
|
|
19 #ifdef FD_SET
|
|
20 #undef FD_SET
|
|
21 #undef FD_CLR
|
|
22 #undef FD_ISSET
|
|
23 #undef FD_ZERO
|
|
24 #endif
|
|
25
|
|
26 /* allow us to provide our own version of fd_set */
|
|
27 #define fd_set ws_fd_set
|
239
|
28 #endif /* 0 */
|
118
|
29
|
|
30 /* avoid duplicate definition of timeval */
|
|
31 #ifdef HAVE_TIMEVAL
|
|
32 #define timeval ws_timeval
|
|
33 #endif
|
|
34
|
|
35 #include <winsock.h>
|
|
36
|
|
37 /* redefine select to reference our version */
|
|
38 #ifdef MUST_REDEF_SELECT
|
|
39 #define select sys_select
|
|
40 #undef MUST_REDEF_SELECT
|
|
41 #endif
|
|
42
|
239
|
43 #if 0 /* What's wrong with winsock.h version ? - kkm */
|
118
|
44 /* revert to our version of FD_SET */
|
|
45 #undef FD_SET
|
|
46 #undef FD_CLR
|
|
47 #undef FD_ISSET
|
|
48 #undef FD_ZERO
|
|
49 #undef fd_set
|
|
50 #include "nt.h"
|
239
|
51 #endif /* 0 */
|
118
|
52
|
|
53 #ifdef HAVE_TIMEVAL
|
|
54 #undef timeval
|
|
55 #endif
|
|
56
|
|
57 /* shadow functions where we provide our own wrapper */
|
|
58 #define socket sys_socket
|
|
59 #define bind sys_bind
|
|
60 #define connect sys_connect
|
|
61 #define htons sys_htons
|
|
62 #define ntohs sys_ntohs
|
|
63 #define inet_addr sys_inet_addr
|
|
64 #define gethostname sys_gethostname
|
|
65 #define gethostbyname sys_gethostbyname
|
|
66 #define getservbyname sys_getservbyname
|
|
67
|
|
68 int sys_socket(int af, int type, int protocol);
|
|
69 int sys_bind (int s, const struct sockaddr *addr, int namelen);
|
|
70 int sys_connect (int s, const struct sockaddr *addr, int namelen);
|
|
71 u_short sys_htons (u_short hostshort);
|
|
72 u_short sys_ntohs (u_short netshort);
|
|
73 unsigned long sys_inet_addr (const char * cp);
|
|
74 int sys_gethostname (char * name, int namelen);
|
|
75 struct hostent * sys_gethostbyname(const char * name);
|
|
76 struct servent * sys_getservbyname(const char * name, const char * proto);
|
|
77
|
|
78 /* we are providing a real h_errno variable */
|
|
79 #undef h_errno
|
|
80 extern int h_errno;
|
|
81
|
|
82 /* map winsock error codes to standard names */
|
|
83 #define EWOULDBLOCK WSAEWOULDBLOCK
|
|
84 #define EINPROGRESS WSAEINPROGRESS
|
|
85 #define EALREADY WSAEALREADY
|
|
86 #define ENOTSOCK WSAENOTSOCK
|
|
87 #define EDESTADDRREQ WSAEDESTADDRREQ
|
|
88 #define EMSGSIZE WSAEMSGSIZE
|
|
89 #define EPROTOTYPE WSAEPROTOTYPE
|
|
90 #define ENOPROTOOPT WSAENOPROTOOPT
|
|
91 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
|
92 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
|
93 #define EOPNOTSUPP WSAEOPNOTSUPP
|
|
94 #define EPFNOSUPPORT WSAEPFNOSUPPORT
|
|
95 #define EAFNOSUPPORT WSAEAFNOSUPPORT
|
|
96 #define EADDRINUSE WSAEADDRINUSE
|
|
97 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
|
98 #define ENETDOWN WSAENETDOWN
|
|
99 #define ENETUNREACH WSAENETUNREACH
|
|
100 #define ENETRESET WSAENETRESET
|
|
101 #define ECONNABORTED WSAECONNABORTED
|
|
102 #define ECONNRESET WSAECONNRESET
|
|
103 #define ENOBUFS WSAENOBUFS
|
|
104 #define EISCONN WSAEISCONN
|
|
105 #define ENOTCONN WSAENOTCONN
|
|
106 #define ESHUTDOWN WSAESHUTDOWN
|
|
107 #define ETOOMANYREFS WSAETOOMANYREFS
|
|
108 #define ETIMEDOUT WSAETIMEDOUT
|
|
109 #define ECONNREFUSED WSAECONNREFUSED
|
|
110 #define ELOOP WSAELOOP
|
|
111 /* #define ENAMETOOLONG WSAENAMETOOLONG */
|
|
112 #define EHOSTDOWN WSAEHOSTDOWN
|
|
113 #define EHOSTUNREACH WSAEHOSTUNREACH
|
|
114 /* #define ENOTEMPTY WSAENOTEMPTY */
|
|
115 #define EPROCLIM WSAEPROCLIM
|
|
116 #define EUSERS WSAEUSERS
|
|
117 #define EDQUOT WSAEDQUOT
|
|
118 #define ESTALE WSAESTALE
|
|
119 #define EREMOTE WSAEREMOTE
|
|
120
|
|
121 #endif /* _SOCKET_H_ */
|
|
122
|
|
123 /* end of socket.h */
|