Perl 套接字连接检查
我已经尝试调试这个 perl 问题有一段时间了,但没有取得进展。我想要做的是确定连接是否是socks4/5 连接。
# ./pctest.pl
Name "main::junk" used only once: possible typo at ./pctest.pl line 60.
Name "main::empty" used only once: possible typo at ./pctest.pl line 60.
IO::Socket::INET: Bad hostname 'C1(X' ...propagated at ./pctest.pl line 52.
我也遇到过这个错误(在我添加或死亡@$;之前):
Can't use an undefined value as a symbol reference at ./pctest.pl line 56.
。
...
$look = IO::Socket::INET->new( PeerAddr => $_, Proto => 'tcp', Timeout => 5 ) or die @$;
$sock4 = pack( "CCS", 4, 1, 80 );
print $look $sock4;
read( $look, $recv, 10 );
( $empty, $granted, $junk ) = unpack( "C C C6", $recv );
if( $granted == 0x5A )
{
print " Yes\n";
}
else
{
print " No\n";
}
...
I've been trying to debug this perl issue for awhile but had made no head way. what I'm trying to do is determain if the connection is a socks4/5 connection.
# ./pctest.pl
Name "main::junk" used only once: possible typo at ./pctest.pl line 60.
Name "main::empty" used only once: possible typo at ./pctest.pl line 60.
IO::Socket::INET: Bad hostname 'C1(X' ...propagated at ./pctest.pl line 52.
I've also had this error (before i added or die @$; at the end):
Can't use an undefined value as a symbol reference at ./pctest.pl line 56.
.
...
$look = IO::Socket::INET->new( PeerAddr => $_, Proto => 'tcp', Timeout => 5 ) or die @$;
$sock4 = pack( "CCS", 4, 1, 80 );
print $look $sock4;
read( $look, $recv, 10 );
( $empty, $granted, $junk ) = unpack( "C C C6", $recv );
if( $granted == 0x5A )
{
print " Yes\n";
}
else
{
print " No\n";
}
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一个错字。
@$
实际上应该是$@
。要消除“可能的拼写错误”消息,并且由于
$empty
和$junk
似乎在代码中未使用,请编写:There's a typo.
@$
should really be$@
.To get rid of the "possible typo" messages and since
$empty
and$junk
seem to be unused in your code, write:只是旁注:我认为您正在考虑 $@,而不是 @$。您需要将代码包含在
构造中。请参阅:
当然,这并没有回答原来的问题:)
Just a side note : I think you are thinking of $@, instead of @$. You need to enclose the code in an
construction. See:
Granted, that doesn't answer the original question :)
该错误消息意味着
IO::Socket::INET->new
调用中PeerAddr
的参数值无效。构造函数期望
PeerAddr
值为主机名或 IP 地址 (nnn.nnn.nnn.nnn)。检查$_
的内容,我打赌你会发现一些不同的东西。The error message means that your parameter value for
PeerAddr
in theIO::Socket::INET->new
call is invalid.The constructor expects the
PeerAddr
value to be a hostname or an IP address (nnn.nnn.nnn.nnn). Check the contents of$_
and I bet you'll find something different.