Solved

How to skip waiting responce from client in CGI

Posted on 2004-10-07
4
152 Views
Last Modified: 2013-12-25
cgi perl, apache2
code:
-------
    my $html = ".... any html code";
    print $html;
    exit;
------
Problem is: after "print $html"  script waits from 0.03 to 30 seconds (possible for client to confirm reception from http server).
Is it possible to skip this delay and exit immediately from script?

Thanks
0
Comment
Question by:VadimS
4 Comments
 
LVL 8

Accepted Solution

by:
inq123 earned 500 total points
Comment Utility
Hi VadimS,

That could be tricky and I have no way/thought of no way to test my solutions out.  But you could try two things:

1. Set $| = 1;  This probably won't work to solve the problem, but could help.
2. Try set STDOUT to non-blocking.  Worth a try:
use Fcntl;

$flags = '';
fcntl(STDOUT, F_GETFL, $flags) or die "Couldn't get flags for HANDLE : $!\n";
$flags |= O_NONBLOCK;
fcntl(STDOUT, F_SETFL, $flags) or die "Couldn't set flags for HANDLE: $!\n";

Even if this doesn't work for print, you could try to use syswrite(STDOUT, $buffer, length $buffer);

Cheers!
0
 
LVL 5

Expert Comment

by:ITcrow
Comment Utility
It is perfectly okay, atleast with my tests with Apache.
Apache takes care of it. I even tried printing enormous data from script and it all shows up on the client without a hiccup.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now