[differences between cumulative patch application and perl5.004_01]
[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);
3e3baf6d 88struct netent * win32_getnetent(void);
89struct netent * win32_getnetbyname(char *name);
90struct netent * win32_getnetbyaddr(long net, int type);
0a753a76 91void win32_setprotoent(int stayopen);
92void win32_setservent(int stayopen);
3e3baf6d 93void win32_endhostent(void);
94void win32_endnetent(void);
95void win32_endprotoent(void);
96void win32_endservent(void);
0a753a76 97
98//
99// direct to our version
100//
101#define htonl win32_htonl
102#define htons win32_htons
103#define ntohl win32_ntohl
104#define ntohs win32_ntohs
105#define inet_addr win32_inet_addr
106#define inet_ntoa win32_inet_ntoa
107
108#define socket win32_socket
109#define bind win32_bind
110#define listen win32_listen
111#define accept win32_accept
112#define connect win32_connect
113#define send win32_send
114#define sendto win32_sendto
115#define recv win32_recv
116#define recvfrom win32_recvfrom
117#define shutdown win32_shutdown
118#define ioctlsocket win32_ioctlsocket
119#define setsockopt win32_setsockopt
120#define getsockopt win32_getsockopt
121#define getpeername win32_getpeername
122#define getsockname win32_getsockname
123#define gethostname win32_gethostname
124#define gethostbyname win32_gethostbyname
125#define gethostbyaddr win32_gethostbyaddr
126#define getprotobyname win32_getprotobyname
127#define getprotobynumber win32_getprotobynumber
128#define getservbyname win32_getservbyname
129#define getservbyport win32_getservbyport
130#define select win32_select
131#define endhostent win32_endhostent
132#define endnetent win32_endnetent
133#define endprotoent win32_endprotoent
134#define endservent win32_endservent
135#define getnetent win32_getnetent
136#define getnetbyname win32_getnetbyname
137#define getnetbyaddr win32_getnetbyaddr
138#define getprotoent win32_getprotoent
139#define getservent win32_getservent
140#define sethostent win32_sethostent
141#define setnetent win32_setnetent
142#define setprotoent win32_setprotoent
143#define setservent win32_setservent
144
145#ifdef __cplusplus
146}
147#endif
148
149#endif // _INC_SYS_SOCKET