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
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) {
* 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(). */