开发者

A problem in socket programming in perl

开发者 https://www.devze.com 2022-12-30 08:41 出处:网络
I write this code : #!/usr/local/bin/perl use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent(agent => \'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Fi

I write this code :

 #!/usr/local/bin/perl
 use strict;
 use LWP::UserAgent;

 my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5');
 $ua->proxy([qw(http https)] => 'http://203.185.28.228:1080' #that is just socks:port);
 my $response = $ua->get("http://www.google.com");
 print $response->code,' ', $response->message,"\n";

but when i execute开发者_JAVA百科 it i get this error: 500 Can't connect to 203.185.28.228:1080 (connect: timeout)

what am i going to do ?


I tested your script, its fine, however I got the only error is with

$ua->proxy([qw(http https)] => 'http://203.185.28.228:1080' #that is just socks:port);

The comments should be out of '()' i.e.

$ua->proxy([qw(http https)] => 'http://203.185.28.228:1080'); #that is just socks:port

Also, please check your internet connectivity. Below is the output i got from your script.

200 Assumed OK


Is it SOCKS5? Does it require you to authenticate? (take a look at your Firefox/IE settings if they use the same proxy)

0

精彩评论

暂无评论...
验证码 换一张
取 消