4 // Provide UNIX compatibility
9 #ifndef _INC_SYS_SOCKET
10 #define _INC_SYS_SOCKET
17 #define PASCAL __stdcall
18 #define WINAPI __stdcall
22 typedef unsigned short WORD;
25 typedef int (FAR WINAPI *FARPROC)();
27 typedef unsigned long DWORD;
33 typedef struct _OVERLAPPED {
39 } OVERLAPPED, *LPOVERLAPPED;
44 #define ENOTSOCK WSAENOTSOCK
48 SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
49 int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen);
50 int win32_closesocket (SOCKET s);
51 int win32_connect (SOCKET s, const struct sockaddr *name, int namelen);
52 int win32_ioctlsocket (SOCKET s, long cmd, u_long *argp);
53 int win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen);
54 int win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen);
55 int win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen);
56 u_long win32_htonl (u_long hostlong);
57 u_short win32_htons (u_short hostshort);
58 unsigned long win32_inet_addr (const char * cp);
59 char * win32_inet_ntoa (struct in_addr in);
60 int win32_listen (SOCKET s, int backlog);
61 u_long win32_ntohl (u_long netlong);
62 u_short win32_ntohs (u_short netshort);
63 int win32_recv (SOCKET s, char * buf, int len, int flags);
64 int win32_recvfrom (SOCKET s, char * buf, int len, int flags,
65 struct sockaddr *from, int * fromlen);
66 int win32_select (int nfds, int *readfds, int *writefds, int *exceptfds, const struct timeval *timeout);
67 int win32_send (SOCKET s, const char * buf, int len, int flags);
68 int win32_sendto (SOCKET s, const char * buf, int len, int flags,
69 const struct sockaddr *to, int tolen);
70 int win32_setsockopt (SOCKET s, int level, int optname,
71 const char * optval, int optlen);
72 SOCKET win32_socket (int af, int type, int protocol);
73 int win32_shutdown (SOCKET s, int how);
75 /* Database function prototypes */
77 struct hostent * win32_gethostbyaddr(const char * addr, int len, int type);
78 struct hostent * win32_gethostbyname(const char * name);
79 int win32_gethostname (char * name, int namelen);
80 struct servent * win32_getservbyport(int port, const char * proto);
81 struct servent * win32_getservbyname(const char * name, const char * proto);
82 struct protoent * win32_getprotobynumber(int proto);
83 struct protoent * win32_getprotobyname(const char * name);
84 struct protoent *win32_getprotoent(void);
85 struct servent *win32_getservent(void);
86 void win32_sethostent(int stayopen);
87 void win32_setnetent(int stayopen);
88 void win32_setprotoent(int stayopen);
89 void win32_setservent(int stayopen);
90 void win32_endhostent();
91 void win32_endnetent();
92 void win32_endprotoent();
93 void win32_endservent();
96 // direct to our version
98 #define htonl win32_htonl
99 #define htons win32_htons
100 #define ntohl win32_ntohl
101 #define ntohs win32_ntohs
102 #define inet_addr win32_inet_addr
103 #define inet_ntoa win32_inet_ntoa
105 #define socket win32_socket
106 #define bind win32_bind
107 #define listen win32_listen
108 #define accept win32_accept
109 #define connect win32_connect
110 #define send win32_send
111 #define sendto win32_sendto
112 #define recv win32_recv
113 #define recvfrom win32_recvfrom
114 #define shutdown win32_shutdown
115 #define ioctlsocket win32_ioctlsocket
116 #define setsockopt win32_setsockopt
117 #define getsockopt win32_getsockopt
118 #define getpeername win32_getpeername
119 #define getsockname win32_getsockname
120 #define gethostname win32_gethostname
121 #define gethostbyname win32_gethostbyname
122 #define gethostbyaddr win32_gethostbyaddr
123 #define getprotobyname win32_getprotobyname
124 #define getprotobynumber win32_getprotobynumber
125 #define getservbyname win32_getservbyname
126 #define getservbyport win32_getservbyport
127 #define select win32_select
128 #define endhostent win32_endhostent
129 #define endnetent win32_endnetent
130 #define endprotoent win32_endprotoent
131 #define endservent win32_endservent
132 #define getnetent win32_getnetent
133 #define getnetbyname win32_getnetbyname
134 #define getnetbyaddr win32_getnetbyaddr
135 #define getprotoent win32_getprotoent
136 #define getservent win32_getservent
137 #define sethostent win32_sethostent
138 #define setnetent win32_setnetent
139 #define setprotoent win32_setprotoent
140 #define setservent win32_setservent
146 #endif // _INC_SYS_SOCKET