[inseparable changes from changes to perl-5.004_01-mt2]
[p5sagit/p5-mst-13.2.git] / win32 / include / sys / socket.h
CommitLineData
0a753a76 1// sys/socket.h
2
3// djl
4// Provide UNIX compatibility
5
0a753a76 6#ifndef _INC_SYS_SOCKET
7#define _INC_SYS_SOCKET
8
7bac28a0 9#ifdef __cplusplus
10extern "C" {
11#endif
0a753a76 12
13#ifndef _WINDOWS_
14#define _WINDOWS_
15
16#define FAR
17#define PASCAL __stdcall
18#define WINAPI __stdcall
19
20#undef WORD
21typedef int BOOL;
22typedef unsigned short WORD;
23typedef void* HANDLE;
24typedef void* HWND;
25typedef int (FAR WINAPI *FARPROC)();
26
27typedef unsigned long DWORD;
28typedef void *PVOID;
29
30#define IN
31#define OUT
32
33typedef struct _OVERLAPPED {
34 DWORD Internal;
35 DWORD InternalHigh;
36 DWORD Offset;
37 DWORD OffsetHigh;
38 HANDLE hEvent;
39} OVERLAPPED, *LPOVERLAPPED;
40
41#endif //_WINDOWS_
42#include <winsock.h>
43
44#define ENOTSOCK WSAENOTSOCK
45#undef HOST_NOT_FOUND
46
47
48SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
49int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen);
50int win32_closesocket (SOCKET s);
51int win32_connect (SOCKET s, const struct sockaddr *name, int namelen);
52int win32_ioctlsocket (SOCKET s, long cmd, u_long *argp);
53int win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen);
54int win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen);
55int win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen);
56u_long win32_htonl (u_long hostlong);
57u_short win32_htons (u_short hostshort);
58unsigned long win32_inet_addr (const char * cp);
59char * win32_inet_ntoa (struct in_addr in);
60int win32_listen (SOCKET s, int backlog);
61u_long win32_ntohl (u_long netlong);
62u_short win32_ntohs (u_short netshort);
63int win32_recv (SOCKET s, char * buf, int len, int flags);
64int win32_recvfrom (SOCKET s, char * buf, int len, int flags,
65 struct sockaddr *from, int * fromlen);
66int win32_select (int nfds, int *readfds, int *writefds, int *exceptfds, const struct timeval *timeout);
67int win32_send (SOCKET s, const char * buf, int len, int flags);
68int win32_sendto (SOCKET s, const char * buf, int len, int flags,
69 const struct sockaddr *to, int tolen);
70int win32_setsockopt (SOCKET s, int level, int optname,
71 const char * optval, int optlen);
72SOCKET win32_socket (int af, int type, int protocol);
73int win32_shutdown (SOCKET s, int how);
74
75/* Database function prototypes */
76
77struct hostent * win32_gethostbyaddr(const char * addr, int len, int type);
78struct hostent * win32_gethostbyname(const char * name);
79int win32_gethostname (char * name, int namelen);
80struct servent * win32_getservbyport(int port, const char * proto);
81struct servent * win32_getservbyname(const char * name, const char * proto);
82struct protoent * win32_getprotobynumber(int proto);
83struct protoent * win32_getprotobyname(const char * name);
84struct protoent *win32_getprotoent(void);
85struct servent *win32_getservent(void);
86void win32_sethostent(int stayopen);
87void win32_setnetent(int stayopen);
88void win32_setprotoent(int stayopen);
89void win32_setservent(int stayopen);
90void win32_endhostent();
91void win32_endnetent();
92void win32_endprotoent();
93void win32_endservent();
94
95//
96// direct to our version
97//
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
104
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
141
142#ifdef __cplusplus
143}
144#endif
145
146#endif // _INC_SYS_SOCKET