Saving files in Perl

From: PuZzLeD (tolavan_at_yahoo.com)
Date: 05/18/04


Date: 18 May 2004 01:03:27 -0700

Hi,
I have a problem here. I am supposed to be saving downloaded web pages
on to a a local cache. I have written a forking proxy server that
reads the request frm the browser and passes the request to the
Internet Gateway and then gets back the data from the internet gateway
and then passes it on to the browser. I need to save the files that
are associated with each request into a local cache. I have attached
the server code below...

server_listenport = IO::Socket::INET->new(
                     LocalPort => $server_listenport,
                     Listen => $listen_queuesize)
           or die "couldnt be a tcp server on port $server_listenport:
$@\n";

while($browser_request=$server_listenport->accept())
{
  if (fork == 0)
  {
   #child
     print " \n\nUsing Child Proceess...\n";
     close ($server_listenport);
     sysread($browser_request,$req_webpage,2048);
     $date_stamp= `date`;
     $internet_gateway =IO::Socket::INET->new(
                           PeerPort=>$IGway_listenport,
                           PeerAddr=>$IGway_hostname) or die " cannot
connect to gateway";

        syswrite($internet_gateway,$req_webpage);
       
        while(sysread($internet_gateway, $recv_webpage, 20480) > 0)
        {
                   syswrite($browser_request,$recv_webpage);
        }
        print "\n\n\tWeb page is now downloaded!!\n\n";
        close($internet_gateway);
        
        exit;
    }
}
  else
  {
    #parent
    print " \n\nUsing Parent Process...\n";
    close($browser_request);
  }
} #end of while

Can some1 help me ?



Relevant Pages

  • Storing downloaded webpages into files
    ... I have written a forking proxy server that ... reads the request frm the browser and passes the request to the ... Internet Gateway and then gets back the data from the internet gateway ... are associated with each request into a local cache. ...
    (comp.lang.perl.misc)
  • Re: Storing downloaded webpages into files
    ... > reads the request frm the browser and passes the request to the ... > Internet Gateway and then gets back the data from the internet gateway ... > and then passes it on to the browser. ... > are associated with each request into a local cache. ...
    (comp.lang.perl.misc)
  • Re: [Full-disclosure] Five Ways to Screw Up SSL
    ... local cache, refresh the cache, then report to you about the websites ... and you could request an ssl cert ... DNS provider. ...
    (Full-Disclosure)
  • Re: Saving files in Perl
    ... You'll have better luck getting answers in comp.lang.perl.misc instead of here. ... > are associated with each request into a local cache. ... There are plenty of caching proxy servers out there, ...
    (comp.lang.perl)