Document mkpath() return value in scalar context.
[p5sagit/p5-mst-13.2.git] / win32 / include / sys / socket.h
CommitLineData
cb69f87a 1/* sys/socket.h */
0a753a76 2
cb69f87a 3/* djl */
4/* Provide UNIX compatibility */
0a753a76 5
0a753a76 6#ifndef _INC_SYS_SOCKET
7#define _INC_SYS_SOCKET
8
7bac28a0 9#ifdef __cplusplus
10extern "C" {
11#endif
0a753a76 12
a835ef8a 13#define WIN32_LEAN_AND_MEAN
14#ifdef __GNUC__
32ce4731 15# define Win32_Winsock
a835ef8a 16#endif
17#include <windows.h>
a86d78b9 18
7bd379e8 19
a86d78b9 20/* Too late to include winsock2.h if winsock.h has already been loaded */
21#ifndef _WINSOCKAPI_
f4257e4d 22# if defined(UNDER_CE) && UNDER_CE <= 300
23 /* winsock2 only for 4.00+ */
24# include <winsock.h>
25# else
a86d78b9 26# include <winsock2.h>
27#endif
f4257e4d 28#endif
0a753a76 29
8d3f517a 30#include "win32.h"
31
0a753a76 32#define ENOTSOCK WSAENOTSOCK
0a753a76 33
55d25626 34#ifdef USE_SOCKETS_AS_HANDLES
35
36#ifndef PERL_FD_SETSIZE
37#define PERL_FD_SETSIZE 64
38#endif
39
40#define PERL_BITS_PER_BYTE 8
41#define PERL_NFDBITS (sizeof(Perl_fd_mask)*PERL_BITS_PER_BYTE)
42
43typedef int Perl_fd_mask;
44
45typedef struct Perl_fd_set {
46 Perl_fd_mask bits[(PERL_FD_SETSIZE+PERL_NFDBITS-1)/PERL_NFDBITS];
47} Perl_fd_set;
48
49#define PERL_FD_CLR(n,p) \
50 ((p)->bits[(n)/PERL_NFDBITS] &= ~((unsigned)1 << ((n)%PERL_NFDBITS)))
51
52#define PERL_FD_SET(n,p) \
53 ((p)->bits[(n)/PERL_NFDBITS] |= ((unsigned)1 << ((n)%PERL_NFDBITS)))
54
55#define PERL_FD_ZERO(p) memset((char *)(p),0,sizeof(*(p)))
56
57#define PERL_FD_ISSET(n,p) \
58 ((p)->bits[(n)/PERL_NFDBITS] & ((unsigned)1 << ((n)%PERL_NFDBITS)))
59
60#else /* USE_SOCKETS_AS_HANDLES */
61
62#define Perl_fd_set fd_set
63#define PERL_FD_SET(n,p) FD_SET(n,p)
64#define PERL_FD_CLR(n,p) FD_CLR(n,p)
65#define PERL_FD_ISSET(n,p) FD_ISSET(n,p)
66#define PERL_FD_ZERO(p) FD_ZERO(p)
67
68#endif /* USE_SOCKETS_AS_HANDLES */
0a753a76 69
70SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
71int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen);
72int win32_closesocket (SOCKET s);
73int win32_connect (SOCKET s, const struct sockaddr *name, int namelen);
74int win32_ioctlsocket (SOCKET s, long cmd, u_long *argp);
75int win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen);
76int win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen);
77int win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen);
78u_long win32_htonl (u_long hostlong);
79u_short win32_htons (u_short hostshort);
80unsigned long win32_inet_addr (const char * cp);
81char * win32_inet_ntoa (struct in_addr in);
82int win32_listen (SOCKET s, int backlog);
83u_long win32_ntohl (u_long netlong);
84u_short win32_ntohs (u_short netshort);
85int win32_recv (SOCKET s, char * buf, int len, int flags);
86int win32_recvfrom (SOCKET s, char * buf, int len, int flags,
87 struct sockaddr *from, int * fromlen);
55d25626 88int win32_select (int nfds, Perl_fd_set *rfds, Perl_fd_set *wfds, Perl_fd_set *xfds,
89 const struct timeval *timeout);
0a753a76 90int win32_send (SOCKET s, const char * buf, int len, int flags);
91int win32_sendto (SOCKET s, const char * buf, int len, int flags,
92 const struct sockaddr *to, int tolen);
93int win32_setsockopt (SOCKET s, int level, int optname,
94 const char * optval, int optlen);
95SOCKET win32_socket (int af, int type, int protocol);
96int win32_shutdown (SOCKET s, int how);
97
98/* Database function prototypes */
99
100struct hostent * win32_gethostbyaddr(const char * addr, int len, int type);
101struct hostent * win32_gethostbyname(const char * name);
102int win32_gethostname (char * name, int namelen);
103struct servent * win32_getservbyport(int port, const char * proto);
104struct servent * win32_getservbyname(const char * name, const char * proto);
105struct protoent * win32_getprotobynumber(int proto);
106struct protoent * win32_getprotobyname(const char * name);
107struct protoent *win32_getprotoent(void);
108struct servent *win32_getservent(void);
109void win32_sethostent(int stayopen);
110void win32_setnetent(int stayopen);
3e3baf6d 111struct netent * win32_getnetent(void);
112struct netent * win32_getnetbyname(char *name);
113struct netent * win32_getnetbyaddr(long net, int type);
0a753a76 114void win32_setprotoent(int stayopen);
115void win32_setservent(int stayopen);
3e3baf6d 116void win32_endhostent(void);
117void win32_endnetent(void);
118void win32_endprotoent(void);
119void win32_endservent(void);
0a753a76 120
55d25626 121#ifndef WIN32SCK_IS_STDSCK
cb69f87a 122
123/* direct to our version */
124
0a753a76 125#define htonl win32_htonl
126#define htons win32_htons
127#define ntohl win32_ntohl
128#define ntohs win32_ntohs
129#define inet_addr win32_inet_addr
130#define inet_ntoa win32_inet_ntoa
131
132#define socket win32_socket
133#define bind win32_bind
134#define listen win32_listen
135#define accept win32_accept
136#define connect win32_connect
137#define send win32_send
138#define sendto win32_sendto
139#define recv win32_recv
140#define recvfrom win32_recvfrom
141#define shutdown win32_shutdown
3a25acb4 142#define closesocket win32_closesocket
0a753a76 143#define ioctlsocket win32_ioctlsocket
144#define setsockopt win32_setsockopt
145#define getsockopt win32_getsockopt
146#define getpeername win32_getpeername
147#define getsockname win32_getsockname
148#define gethostname win32_gethostname
149#define gethostbyname win32_gethostbyname
150#define gethostbyaddr win32_gethostbyaddr
151#define getprotobyname win32_getprotobyname
152#define getprotobynumber win32_getprotobynumber
153#define getservbyname win32_getservbyname
154#define getservbyport win32_getservbyport
155#define select win32_select
156#define endhostent win32_endhostent
157#define endnetent win32_endnetent
158#define endprotoent win32_endprotoent
159#define endservent win32_endservent
160#define getnetent win32_getnetent
161#define getnetbyname win32_getnetbyname
162#define getnetbyaddr win32_getnetbyaddr
163#define getprotoent win32_getprotoent
164#define getservent win32_getservent
165#define sethostent win32_sethostent
166#define setnetent win32_setnetent
167#define setprotoent win32_setprotoent
168#define setservent win32_setservent
169
55d25626 170#ifdef USE_SOCKETS_AS_HANDLES
171#undef fd_set
172#undef FD_SET
173#undef FD_CLR
174#undef FD_ISSET
175#undef FD_ZERO
176#define fd_set Perl_fd_set
177#define FD_SET(n,p) PERL_FD_SET(n,p)
178#define FD_CLR(n,p) PERL_FD_CLR(n,p)
179#define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
180#define FD_ZERO(p) PERL_FD_ZERO(p)
181#endif /* USE_SOCKETS_AS_HANDLES */
182
183#endif /* WIN32SCK_IS_STDSCK */
184
0a753a76 185#ifdef __cplusplus
186}
187#endif
188
cb69f87a 189#endif /* _INC_SYS_SOCKET */