Solved

Stopping CGI/Perl  when Browser stops listening

Posted on 1998-07-24
1
207 Views
Last Modified: 2013-12-25
I have made a CGI-Perl script which feeds back multple JPG images to a <IMG> tag client call.  The multi images can run up to 200 JPGs.  One thing that's for sure is the client won't sit there for all 200 JPGS to show on their screen as an animation (they'll leave my page to somewhere else).  Now if this is the case, I'd hate for my CGI script to "keep sending" JPG images if there's no one watching it.

Therefore, I'd like to have my Perl script "immediately" stop sending images and quit if the client browser has stopped accepting images.  I remeber such a command exists in Perl but I totally forget what it is.  Would you know the answer?

Thanks.
0
Comment
Question by:ljaques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
alamo earned 0 total points
ID: 1831149
You probably have a line to copy the image file to STDOUT which looks something like:
print <IN>;

Change it to:
print (<IN>) || last;

When the user hits stop on the browser, the server kills STDOUT and thus print fails. (Bet you didn't know print was a function that returns true or false, most people don't use it that way). What you are going to print needs to be enclised in () so that it doesn't try to print <IN>||last, which won't work.

Hope this helps!

p.s. I would have told you this last time if I had realized it, I knew it was possible but had never actually figured out how to do it. Now I have :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 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