The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 09-29-2008
Dabheeruz Dabheeruz is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 19
Proxy server/client in Perl

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

Code:
#!/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);