P
PuZzLeD
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 ?
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 ?