Streaming HTML

I remember about a year ago, there was a chat site that used HTML as it's medium.   It was somewhat impressive in one area, which was that it had Streaming Chat or more appropriately the chat's posts werealways being received and never stopped until a certain limit hit a which then stopped the stream.

I have been trying to reproduce this with no luck.    I have seen similar "streaming" effects when you downloaded a large HTML file and had to wait.   Yet, generating normal HTML will not allow you to do this simply using a while loop and sleep (it shows nothing whatsoever, not even a simple print between a while).  

I was looking into a server push operation.  But it seems (at least in the CGI::Push module for Perl) that it can display multiple pages and not simply a very long stream.   Anyone have a chance to implement such a scheme using preferably Perl?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

to get browser to show start of page, before sending has finished can use fflush(stdout), but it depends on Apache version
mfosterAuthor Commented:
Perl is a bit higher level then C/C++ in terms of programming languages.   Now does this require manipulation of the Apache server itself either using a module or is there a way to make the programming language tell apache to flush?
imho it was Apache 1.3.9 or 1.3.6 which sends output to browser if CGI flushes stdout. prior versions of Apache waits until CGI prog exits ...
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

mfosterAuthor Commented:
I have version 1.3.11 compiled and installed.  Now all I need to know is how to make my CGI script tell Apache to flush to output.  Anyone use Perl for this?
look at Perl manual - for command on flushing output.
or compile and try this C prog:

#include <stdio.h>

int main(void)
  int i;

  printf("Content-type: text/html\n\n");

  for (i=0; i<10; i++)
    printf("<h2> TEXT #: %d </h2>\n", i);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mfosterAuthor Commented:
Turns out you set the autoflush bit on the STDOUT filehandle to correct the problem.  Quite interesting, as it actually calls fflush() for you after every print.  

I added the code below for anyone interested.

# Filehandle control
use FileHandle;

# Flush standard output
autoflush STDOUT 1;

# Make sure change takes place
print "";

# Display of streaming HTML information
print $cgi->start_html();
   for (my $count=0; $count < 10000; $count++)
           print "<P>$count</P>";

print $cgi->end_html();
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.