# define socketpair PerlSock_socketpair
# endif /* NETWARE && USE_STDIO */
-# ifdef USE_SOCKETS_AS_HANDLES
-# undef fd_set
-# undef FD_SET
-# undef FD_CLR
-# undef FD_ISSET
-# undef FD_ZERO
-# define fd_set Perl_fd_set
-# define FD_SET(n,p) PERL_FD_SET(n,p)
-# define FD_CLR(n,p) PERL_FD_CLR(n,p)
-# define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
-# define FD_ZERO(p) PERL_FD_ZERO(p)
-# endif /* USE_SOCKETS_AS_HANDLES */
+# undef fd_set
+# undef FD_SET
+# undef FD_CLR
+# undef FD_ISSET
+# undef FD_ZERO
+# define fd_set Perl_fd_set
+# define FD_SET(n,p) PERL_FD_SET(n,p)
+# define FD_CLR(n,p) PERL_FD_CLR(n,p)
+# define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
+# define FD_ZERO(p) PERL_FD_ZERO(p)
# endif /* NO_XSLOCKS */
#endif /* PERL_IMPLICIT_SYS && !PERL_CORE */
#undef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
-#ifdef USE_SOCKETS_AS_HANDLES
-
#ifndef PERL_FD_SETSIZE
#define PERL_FD_SETSIZE 64
#endif
#define PERL_FD_ISSET(n,p) \
((p)->bits[(n)/PERL_NFDBITS] & ((unsigned)1 << ((n)%PERL_NFDBITS)))
-#else /* USE_SOCKETS_AS_HANDLES */
-
-#define Perl_fd_set fd_set
-#define PERL_FD_SET(n,p) FD_SET(n,p)
-#define PERL_FD_CLR(n,p) FD_CLR(n,p)
-#define PERL_FD_ISSET(n,p) FD_ISSET(n,p)
-#define PERL_FD_ZERO(p) FD_ZERO(p)
-
-#endif /* USE_SOCKETS_AS_HANDLES */
-
SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen);
int win32_closesocket (SOCKET s);
#define setprotoent win32_setprotoent
#define setservent win32_setservent
-#ifdef USE_SOCKETS_AS_HANDLES
#undef fd_set
#undef FD_SET
#undef FD_CLR
#define FD_CLR(n,p) PERL_FD_CLR(n,p)
#define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
#define FD_ZERO(p) PERL_FD_ZERO(p)
-#endif /* USE_SOCKETS_AS_HANDLES */
#endif /* WIN32SCK_IS_STDSCK */
return f;
}
-#ifndef USE_SOCKETS_AS_HANDLES
-#undef fdopen
-#define fdopen my_fdopen
-#endif
-
DllExport FILE *
win32_fdopen(int handle, const char *mode)
{
#define DOSISH 1 /* no escaping our roots */
#define OP_BINARY O_BINARY /* mistake in in pp_sys.c? */
-/* Define USE_SOCKETS_AS_HANDLES to enable emulation of windows sockets as
- * real filehandles. XXX Should always be defined (the other version is untested) */
-#define USE_SOCKETS_AS_HANDLES
-
/* read() and write() aren't transparent for socket handles */
#define PERL_SOCK_SYSREAD_IS_RECV
#define PERL_SOCK_SYSWRITE_IS_SEND
DllExport void win32_get_child_IO(child_IO_table* ptr);
DllExport HWND win32_create_message_window(void);
-#ifndef USE_SOCKETS_AS_HANDLES
-extern FILE * my_fdopen(int, char *);
-#endif
extern int my_fclose(FILE *);
extern char * win32_get_privlib(const char *pl, STRLEN *const len);
extern char * win32_get_sitelib(const char *pl, STRLEN *const len);
char Wstrerror_buffer[512];
struct servent Wservent;
char Wgetlogin_buffer[128];
-# ifdef USE_SOCKETS_AS_HANDLES
int Winit_socktype;
-# endif
char Wcrypt_buffer[30];
# ifdef USE_RTL_THREAD_API
void * retv; /* slot for thread return value */
#include <io.h>
/* thanks to Beverly Brown (beverly@datacube.com) */
-#ifdef USE_SOCKETS_AS_HANDLES
-# define OPEN_SOCKET(x) win32_open_osfhandle(x,O_RDWR|O_BINARY)
-# define TO_SOCKET(x) _get_osfhandle(x)
-#else
-# define OPEN_SOCKET(x) (x)
-# define TO_SOCKET(x) (x)
-#endif /* USE_SOCKETS_AS_HANDLES */
+#define OPEN_SOCKET(x) win32_open_osfhandle(x,O_RDWR|O_BINARY)
+#define TO_SOCKET(x) _get_osfhandle(x)
#define StartSockets() \
STMT_START { \
wsock_started = 1;
}
-#ifndef USE_SOCKETS_AS_HANDLES
-#undef fdopen
-FILE *
-my_fdopen(int fd, char *mode)
-{
- FILE *fp;
- char sockbuf[256];
- int optlen = sizeof(sockbuf);
- int retval;
-
- if (!wsock_started)
- return(fdopen(fd, mode));
-
- retval = getsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, sockbuf, &optlen);
- if(retval == SOCKET_ERROR && WSAGetLastError() == WSAENOTSOCK) {
- return(fdopen(fd, mode));
- }
-
- /*
- * If we get here, then fd is actually a socket.
- */
- Newxz(fp, 1, FILE); /* XXX leak, good thing this code isn't used */
- if(fp == NULL) {
- errno = ENOMEM;
- return NULL;
- }
-
- fp->_file = fd;
- if(*mode == 'r')
- fp->_flag = _IOREAD;
- else
- fp->_flag = _IOWRT;
-
- return fp;
-}
-#endif /* USE_SOCKETS_AS_HANDLES */
-
-
u_long
win32_htonl(u_long hostlong)
{
win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const struct timeval* timeout)
{
int r;
-#ifdef USE_SOCKETS_AS_HANDLES
int i, fd, save_errno = errno;
FD_SET nrd, nwr, nex;
bool just_sleep = TRUE;
}
}
errno = save_errno;
-#else
- SOCKET_TEST_ERROR(r = select(nfds, rd, wr, ex, timeout));
-#endif
return r;
}
return r;
}
-#ifdef USE_SOCKETS_AS_HANDLES
-#define WIN32_OPEN_SOCKET(af, type, protocol) open_ifs_socket(af, type, protocol)
-
void
convert_proto_info_w2a(WSAPROTOCOL_INFOW *in, WSAPROTOCOL_INFOA *out)
{
return out;
}
-#else
-#define WIN32_OPEN_SOCKET(af, type, protocol) socket(af, type, protocol)
-#endif
-
SOCKET
win32_socket(int af, int type, int protocol)
{
SOCKET s;
-#ifndef USE_SOCKETS_AS_HANDLES
- SOCKET_TEST(s = socket(af, type, protocol), INVALID_SOCKET);
-#else
StartSockets();
- if((s = WIN32_OPEN_SOCKET(af, type, protocol)) == INVALID_SOCKET)
+ if((s = open_ifs_socket(af, type, protocol)) == INVALID_SOCKET)
errno = WSAGetLastError();
else
s = OPEN_SOCKET(s);
-#endif /* USE_SOCKETS_AS_HANDLES */
return s;
}