我尝试过Net :: RawIP和Net :: Write :: Layer3。如果我在网络中提供特定的IP地址,它工作正常。虽然我得到了
sendto() at /usr/lib/perl5/Net/RawIP.pm line 630. shell returned 13
或
Net::Write::Layer::send: Permission denied
如果我将目的地地址更改为66.66.66.255
任何想法?
我正在使用的代码在这里
use Net::Write::Layer qw(:constants);
use Net::Write::Layer3;
use NetAddr::IP;
use Net::RawIP;
$message = "Foo";
# using Net::RawIP
$n = Net::RawIP->new({
ip => {
tos => 0xC0,
daddr => '66.66.66.2',
protocol => 2,
},
generic => {
data => $message
}
});
$n->send;
# using Net::Write::Layer3
my $desc = Net::Write::Layer3->new(
dst => '66.66.66.2',
protocol => '2',
family => NW_AF_INET,
);
$desc->open;
$desc->send($message);
$desc->close;
答案 0 :(得分:1)
错误13通常是EACCES
- 即您没有足够的权限发送到广播套接字。