perl中socket编程的一个问题

时间:2010-05-11 10:05:12

标签: perl sockets

我写这段代码:

 #!/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";

但是当我执行它时,我收到此错误: 500无法连接到203.185.28.228:1080(连接:超时)

我该怎么办?

2 个答案:

答案 0 :(得分:1)

我测试了你的脚本,很好,但是我唯一的错误是

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

评论应该是'()',即

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

另外,请检查您的互联网连接。以下是我从脚本中获得的输出。

200 Assumed OK

答案 1 :(得分:0)

是SOCKS5吗?它需要您进行身份验证吗? (如果他们使用相同的代理,请查看您的Firefox / IE设置)