From: Gurusamy Sarathy Date: Wed, 24 Dec 1997 04:21:30 +0000 (+0000) Subject: [win32] support ioctl() on sockets (does what ioctlsocket() does) to make X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f998180f71571d04f7a71972eb8eb78805338f5c;p=p5sagit%2Fp5-mst-13.2.git [win32] support ioctl() on sockets (does what ioctlsocket() does) to make non-blocking IO on sockets possible p4raw-id: //depot/win32/perl@387 --- diff --git a/README.win32 b/README.win32 index 940c498..3727b2c 100644 --- a/README.win32 +++ b/README.win32 @@ -503,7 +503,7 @@ The following functions are currently unavailable: C, C, C, C, C, C, C and related security functions, C, C, C, C, C, -C, C, C, C, C, C, +C, C, C, C, C, C, C<*netent()>, C<*protoent()>, C<*servent()>, C<*hostent()>, C. This list is possibly incomplete. @@ -519,6 +519,11 @@ The four-argument C call is only supported on sockets. =item * +The C call is only supported on sockets (where it provides the +functionality of ioctlsocket() in the Winsock API). + +=item * + C<$?> ends up with the exitstatus of the subprocess (this is different from Unix, where the exitstatus is actually given by "$? >> 8"). Failure to spawn() the subprocess is indicated by setting $? to diff --git a/dosish.h b/dosish.h index c71ecd5..5704c78 100644 --- a/dosish.h +++ b/dosish.h @@ -46,6 +46,7 @@ #define TMPPATH "plXXXXXX" #ifdef WIN32 +#define HAS_IOCTL #define HAS_UTIME #define HAS_KILL #endif diff --git a/win32/makedef.pl b/win32/makedef.pl index 766a426..27bcf95 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -507,6 +507,7 @@ win32_times win32_alarm win32_open_osfhandle win32_get_osfhandle +win32_ioctl Perl_win32_init Perl_init_os_extras Perl_getTHR diff --git a/win32/win32.c b/win32/win32.c index bdfb3e2..8f96611 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -610,15 +610,6 @@ kill(int pid, int sig) * File system stuff */ -#if 0 -int -ioctl(int i, unsigned int u, char *data) -{ - croak("ioctl not implemented!\n"); - return -1; -} -#endif - DllExport unsigned int win32_sleep(unsigned int t) { diff --git a/win32/win32iop.h b/win32/win32iop.h index d565cb5..5e03f95 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -114,6 +114,7 @@ DllExport int win32_times(struct tms *timebuf); DllExport unsigned win32_alarm(unsigned int sec); DllExport int win32_flock(int fd, int oper); DllExport int win32_stat(const char *path, struct stat *buf); +DllExport int win32_ioctl(int i, unsigned int u, char *data); #ifdef HAVE_DES_FCRYPT DllExport char * win32_crypt(const char *txt, const char *salt); @@ -138,6 +139,7 @@ END_EXTERN_C #undef sleep #undef times #undef alarm +#undef ioctl #ifdef __BORLANDC__ #undef ungetc @@ -236,6 +238,7 @@ END_EXTERN_C #define sleep win32_sleep #define times win32_times #define alarm win32_alarm +#define ioctl win32_ioctl #ifdef HAVE_DES_FCRYPT #undef crypt diff --git a/win32/win32sck.c b/win32/win32sck.c index 64d1a0a..a6e7a99 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -223,7 +223,7 @@ win32_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen) return r; } -int +DllExport int win32_ioctlsocket(SOCKET s, long cmd, u_long *argp) { int r; @@ -466,6 +466,28 @@ win32_getservbyport(int port, const char *proto) return r; } +int +win32_ioctl(int i, unsigned int u, char *data) +{ + u_long argp = (u_long)data; + int retval; + + if (!wsock_started) { + croak("ioctl implemented only on sockets"); + /* NOTREACHED */ + } + + retval = ioctlsocket(TO_SOCKET(i), (long)u, &argp); + if (retval == SOCKET_ERROR) { + if (WSAGetLastError() == WSAENOTSOCK) { + croak("ioctl implemented only on sockets"); + /* NOTREACHED */ + } + errno = WSAGetLastError(); + } + return retval; +} + char FAR * win32_inet_ntoa(struct in_addr in) {