From: Gurusamy Sarathy Date: Sat, 21 Nov 1998 08:45:06 +0000 (+0000) Subject: another win32 portability fix: make sysread() and syswrite() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7092146033201511b749e3a5ff31247e203604d;p=p5sagit%2Fp5-mst-13.2.git another win32 portability fix: make sysread() and syswrite() work on sockets p4raw-id: //depot/perl@2255 --- diff --git a/pp_sys.c b/pp_sys.c index 8fa38f2..b3de2f8 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1422,7 +1422,17 @@ PP(pp_sysread) Zero(buffer+bufsize, offset-bufsize, char); } if (PL_op->op_type == OP_SYSREAD) { - length = PerlLIO_read(PerlIO_fileno(IoIFP(io)), buffer+offset, length); +#ifdef PERL_SOCK_SYSREAD_IS_RECV + if (IoTYPE(io) == 's') { + length = PerlSock_recv(PerlIO_fileno(IoIFP(io)), + buffer+offset, length, 0); + } + else +#endif + { + length = PerlLIO_read(PerlIO_fileno(IoIFP(io)), + buffer+offset, length); + } } else #ifdef HAS_SOCKET__bad_code_maybe @@ -1534,7 +1544,17 @@ PP(pp_send) offset = 0; if (length > blen - offset) length = blen - offset; - length = PerlLIO_write(PerlIO_fileno(IoIFP(io)), buffer+offset, length); +#ifdef PERL_SOCK_SYSWRITE_IS_SEND + if (IoTYPE(io) == 's') { + length = PerlSock_send(PerlIO_fileno(IoIFP(io)), + buffer+offset, length, 0); + } + else +#endif + { + length = PerlLIO_write(PerlIO_fileno(IoIFP(io)), + buffer+offset, length); + } } #ifdef HAS_SOCKET else if (SP > MARK) { diff --git a/win32/win32.h b/win32/win32.h index b52ef4e..fef3cbc 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -104,6 +104,11 @@ struct tms { * 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 + + /* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls * to read the environment, bypassing the runtime's (usually broken) * facilities for accessing the same. See note in util.c/my_setenv(). */