I have been toying with a Proxy client/server app that will listen on the CLIENT system on lets say port 7070. User's browser proxy setting is configured for "localhost" port "7070".
When this proxy app gets a request for a URL it should FETCH the URL and display it on the browser.
I already made the listener portion of the script (it was easy) but how can I then call and get the URL that the user will request on their browser and display it to the browser acting like a proxy.
Here is the code so far. I am totally stuck ..any help is highly appreciated
#!/usr/bin/perl
use IO::Socket;
my $sock= new IO::Socket::INET (
LocalHost=> 'localhost',
LocalPort=> '7070',
Proto=> 'tcp',
Listen=> 1,
Reuse=> 1,
Type=> SOCK_STREAM,
);
die "Could not create socket: $!\n" unless $sock;
my $new_sock = $sock->accept();
while (<$new_sock>) {
print $_;
}
close ($sock);