Perl IO::Socket - Cannot determine peer address
I am having an issue stemming from IO/Socket.pm on or around line 251.
croak 'send: Cannot determine peer address'
unless($peer);
Basically we are opening a connection up, and sending data to it. For some reason after 10-20 seconds this error gets thrown.
send: Cannot determine peer address
Any ideas??
#!/usr/bin/perl
package Dialer;
use Data::Dumper;
use IO::Socket;
$sock = IO::Socket::INET->new(PeerAddr => '255.255.255.255',
PeerPort => '5038',
Proto => 'tcp');
$res = $sock->send("Action: Login\r\nUsername: dunzo\r\nSecret: 123456789\r\nEvents: \r\n\r\n");
sleep(5);
while(1==1) {
$res = $sock->send("Action: Originate\r\nChannel: Local/123123@dunzodial\r\nExten: 123123\r开发者_如何学Python\nContext: dunzo\r\nTimeout: 60000\r\nVariable: \r\nAsync: yes\r\nCallerID:
1234567890\r\nPriority: 1\r\n\r\n");
$incr++;
sleep(1);
print $incr."\n";
}
$sock = IO::Socket::INET->new(PeerAddr => '255.255.255.255',
PeerPort => '5038',
Proto => 'tcp');
For TCP protocol, 255.255.255.255
isn't a valid unicast IP address. In this case, IO::Socket::INET treat 255.255.255.255
as a domain name. It will request the IP address by query your DNS server with host name 255.255.255.255
. Obviously there isn't such a record, the DNS query operation will be timeout. That's why you got error after 10~20 seconds.
精彩评论