> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: 10 April 2000 15:00
> To: [EMAIL PROTECTED]
> Subject: Re: Syswrite() returns undef on socket write > 65535 bytes
>
>
> In article <FB30E6123B22D211B52800A0C9CFBB19010C0E9F@LONES2>,
> "BAZLEY, Sebastian" <[EMAIL PROTECTED]> writes:
> > On VMS, syswrite() returns undef if one tries to write more
> than 65535 bytes
> > on a socket.
>
> Probably to more devices than just a socket; my bet is that any
> non-file-structured device would have the problem.
>
> As should be obvious, this is the (in)famous "length as an
> unsigned short"
> in QIO calls. Perl calls the CRTL `write' function which
> does the QIO.
The size limitation is indeed an obvious number, but I did not know (or I'd
forgotten) that QIO lengths are not long (!) ...
In pp_sys.c pp_syswrite() calls pp_send(), which calls the socket send() or
sendto() routines under some circumstances; but I guess those eventually use
QIOs.
>
> > This can cause problems for other modules, so how about
> forcing the call to
> > write a maximum of 65535 bytes? [The caller should always
> be prepared to
> > handle a shorter write, so this should not break any code.]
>
> Should, but watch out; I've seen plenty of unix code with:
>
> if (write(fd, buf, n) != n) {die_horribly}
>
I don't know how write() is supposed to behave on Unix, but such code looks
broken to me ...
> > It seems to me that undef should be reserved for more
> "serious" errors.
> >
> > Anyone agree/disagree/other solutions?
> >
> > [This problem showed up on VMS 7.2-1 with UCX 5.0A. I have
> not tried any
> > other combinations.]
>
> Watch out though, if you just break at a random place it's
> possible you'll
> have problems with carriage control bytes.
Good point.
>
> For example in Perl if you do a print to a mailbox:
>
> print MBX "blah blah\n";
>
> The "\n" is stripped (by the CRTL) before writing to the mailbox. If
> you read from a mailbox, a "\n" is tacked on the end of the record by
> the CRTL before Perl gets the data.
Yes, but writes to mailboxes are surely unlikely to be more than 65535 bytes
long, surely?
>
> My *bet* is that you want to break at \n bytes, but you'll have to try
> it and see.
I came across the problem when trying to use FTP via LWP to upload a Zip
file. Forcing the max chunk size to 65535 (in Net::FTP::I) fixed the
problem.
But when I contacted the Net::FTP author, he not unreasonably suggested that
syswrite() ought to write as much as it can, and return the length of what
it has written. Hence my original posting ... apologies for not making this
clear originally.
If the code can be fixed so that it only truncates writes that would
otherwise have failed, then this ought to be an improvement, no?
--
Sebastian Bazley <[EMAIL PROTECTED]>
The opinions expressed herein are my own, and are not necessarily endorsed
by my employer ...
___________________________________________________________________________
This email is confidential and intended solely for the use of the
individual to whom it is addressed. Any views or opinions presented are
solely those of the author and do not necessarily represent those of
Sema Group.
If you are not the intended recipient, be advised that you have received this
email in error and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited.
If you have received this email in error please notify the Sema Group
Helpdesk by telephone on +44 (0) 121 627 5600.
___________________________________________________________________________