[asterisk-users] AMI perl daemon
Alex Balashov
abalashov at evaristesys.com
Mon May 16 15:21:25 CDT 2011
On 05/16/2011 04:17 PM, vip killa wrote:
> forgive me for i am very new to asterisk and perl. but how could you
> detect if you were disconnected from AMI?
if(defined($mgr_sock)) would evaluate to false. That's all you need to
do with the plain vanilla blocking I/O you're using now.
Down the road, if non-blocking I/O is set, there are other strategies.
The traditional way was an ioctl() FIONREAD that returned 0 for the
bytes value, though the ioctl() call did not fail:
require 'sys/ioctl.ph';
...
my $bytes_waiting = pack("L", 0);
ioctl($mgr_sock, FIONREAD(), $bytes_wating);
$bytes_waiting = unpack("L", $bytes_waiting);
if($bytes_waiting == 0) {
# Far-end disconnected.
close($mgr_sock);
return;
}
--
Alex Balashov - Principal
Evariste Systems LLC
260 Peachtree Street NW
Suite 2200
Atlanta, GA 30303
Tel: +1-678-954-0670
Fax: +1-404-961-1892
Web: http://www.evaristesys.com/
More information about the asterisk-users
mailing list