2ge has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use URI; use IO::Socket; use Net::SOCKS; #my $server = '68.34.100.143:29992'; #works #my $server = '68.48.32.219:38884'; #opens, but no content my $server = '217.237.150.97:80'; #no timeout !?! my ($ip, $port) = ($1, $2) if $server =~ /([^:]+):(.*)/; my $page = URI->new('http://www.2ge.us/index.html'); my $fh = IO::Socket::INET-> new(PeerAddr => $ip, PeerPort => $port, Proto => 'tcp', Timeout => 5 ) || die "Can't open $server\n"; print "$server opened, trying socks5\n"; my $sock = new Net::SOCKS(socks_addr => $ip, socks_port => $port, user_id => '', user_password => '', force_nonanonymous => 0, protocol_version => 5) || die "Can't create socket\n"; my $conn = $sock->connect(peer_addr => inet_ntoa(inet_aton($page->host +())), peer_port => $page->port() ) || die "Can't connect to socks5 server\n"; #how to define timeout here ^^^ print "con. status:",Net::SOCKS::status_message($sock->param('status_n +um')),"\n"; $conn->autoflush(1); print "downloading...\n"; print $conn "GET " . $page->path() . " HTTP/1.1\n"; print $conn "Host: " . $page->host() . "\n"; print $conn "Connection: close\n\n"; while (<$conn>) { print } $sock->close(); __END__
2004-12-08 Janitored by Arunbear - added readmore tags, as per Monastery guidelines
|
|---|