in reply to Re: syswrite strange behaviour on some systems
in thread syswrite strange behaviour on some systems

Thanks AgentM

Well, my $write always ends "\015\012". Which should be nice... sounds like I am confused about I/O though. I read the FAQ which says:

Perl does not support truly unbuffered output (except insofar as you can `syswrite(OUT, $char, 1)').

But the packet at a time thing sounds like it might be the problem...

Update What is weird is that the syswrite loop runs OK with any other server but not this one.

dave hj~

  • Comment on Re: Re: syswrite strange behaviour on some systems

Replies are listed 'Best First'.
(tye)Re: syswrite strange behaviour on some systems
by tye (Sage) on Apr 02, 2001 at 23:01 UTC

    Well, the FAQ is misleading (*sigh*). Perl does support unbuffered I/O via syswrite and sysread. Perhaps they meant that Perl doesn't support unbuffered I/O via other functions such as print and printf (except that you can have the buffer autoflushed as described).

    <Update> And the difference between unbuffered and "command buffered" (as the FAQ calls it) is pretty subtle and usually unimportant so you might as well use "command buffered" for most things. The only time that I think it matters is that you can get into trouble by mixing buffered and unbuffered I/O to/from the same file handle. Nothing external to your script should be able to tell the difference between the two. </update>

    In particular, you don't have to specify a write length of 1 in order for syswrite to be unbuffered. Also, I encourage you to just leave the length argument off and write syswrite(WHOIS,$write).

    By writing things one byte at a time, your data might get sent with as few as one byte per packet. I could see this confusing a poorly written server.

            - tye (but my friends call me "Tye")
      Nice one Tye, thanks.

      Just one thing: I seem to recall having been bitten before by a versioning problem where some systems don't like syswrite unless you include the third "length" argument. Can't remember if this was a system thing, or a perl version thing. But it is worth knowing if you try to write XP Perl.

      dave hj~

        Yes, the length wasn't optional in Perl 5.004 and prior (perhaps even Perl5.005). I recall grumbling about how stupid it was to require a length. (:

                - tye (but my friends call me "Tye")