Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what is unbuffered stdout ?

36 views
Skip to first unread message

David Zlotchenko

unread,
Sep 6, 1995, 3:00:00 AM9/6/95
to
Thank you Paul for redirecting me.

I sure use nph- name for the script. But what is "unbuffered stdout" ?
C/Perl example ?

Thank you.
David.


On Tue, 5 Sep 1995, Paul Phillips wrote:

>
>
> On Tue, 5 Sep 1995, David Zlotchenko wrote:
>
>
> This isn't appropriate for www-talk, please take questions like this to
> comp.infosystems.www.authoring.cgi. The answer is that the server is
> buffering the data, and you need to use an nph- script and an unbuffered
> stdout to get the data to the client immediately. Documentation on nph-
> scripts is available at <URL:http://hoohoo.ncsa.uiuc.edu/>
>
> --
> Paul Phillips | "Click _here_ if you do not
> <URL:mailto:pa...@cerf.net> | have a graphical browser"
> <URL:http://www.primus.com/staff/paulp/> | -- Canter and Siegel, on
> <URL:pots://+1-619-220-0850/is/paul/there?> | their short-lived web site
>

--
--
David Zlotchenko
Research Services Phone: (01) (615) 974-6601
The University of Tennessee Email: zlot...@solar.rtd.utk.edu

Paul Phillips

unread,
Sep 6, 1995, 3:00:00 AM9/6/95
to
In article <42isv5$f...@gaia.ns.utk.edu> zlot...@solar.rtd.utk.edu
(David Zlotchenko) writes:
>Thank you Paul for redirecting me.
>
>I sure use nph- name for the script. But what is "unbuffered stdout" ?
>C/Perl example ?

Unbuffered stdout means that the data is not buffered by the script
before being sent to the client.

C example:

setvbuf(stdout, (char *)NULL, _IONBF, 0);

Perl example:

$| = 1;

man setvbuf for more on the C example.
man perlvar for more on the perl example (needs perl5 man pages)

-PSP

--
"I have had two many friends KILLED by their own weapons during a mugging. By
the way they all were trainded in how to yous those weapons too."
-- Michael Shawn Barhorst, Phi Alpha Delta (pre law)
alt.folklore.college

Tom Christiansen

unread,
Sep 6, 1995, 3:00:00 AM9/6/95
to
[courtesy cc of this posting sent to cited author via email]

In comp.infosystems.www.authoring.cgi,

zlot...@solar.rtd.utk.edu (David Zlotchenko) writes:
:Thank you Paul for redirecting me.
:
:I sure use nph- name for the script. But what is "unbuffered stdout" ?
:C/Perl example ?

perl, v4:

$| = 1;

perl, v5:

use English;
$AUTOFLUSH = 1;

perl, v5:

use FileHandle;
STDOUT->autoflush();

C: see the setlinebuf() or setbuf() functions.

--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tch...@mox.perl.com

The probability of someone watching you is proportional to the
stupidity of your action.

Larry Wall

unread,
Sep 7, 1995, 3:00:00 AM9/7/95
to
In article <42knbk$j...@news.cerf.net>,
Paul Phillips <pa...@nic.cerf.net> wrote:
: In article <42isv5$f...@gaia.ns.utk.edu> zlot...@solar.rtd.utk.edu
: (David Zlotchenko) writes:
: >Thank you Paul for redirecting me.
: >
: >I sure use nph- name for the script. But what is "unbuffered stdout" ?
: >C/Perl example ?
:
: Unbuffered stdout means that the data is not buffered by the script

: before being sent to the client.
:
: C example:
:
: setvbuf(stdout, (char *)NULL, _IONBF, 0);
:
: Perl example:
:
: $| = 1;
:
: man setvbuf for more on the C example.
: man perlvar for more on the perl example (needs perl5 man pages)

Just a minor clarification here. Setting $| in Perl makes it unbuffered
only in the sense that nothing is buffered up between print statements, but
not in the sense that each character is output with a separate write()
system call. Perl does what I like to call "command buffering". The
equivalent in C is to put an fflush() after every printf().

For the purposes of CGI, of course, it makes little difference, other
than that command buffering puts less load on your system than does
unbuffering. C programs often set "line buffering" to get around this,
but command buffering is still more efficient, since it doesn't have to
scan the output for newlines. It also flushes less often if you output
multiple lines in one print statement, which Perl programs often do
using "here documents".

Sorry, my pedagogy pedal got stuck...

Larry Wall
lw...@sems.com

0 new messages