[Freeswitch-users] Server Disconnected when SIGINT occured

lakshmanan ganapathy lakindia89 at gmail.com
Wed Jan 13 01:13:03 PST 2010


Hi all,

I've done a sample program (In perl ESL) , which play a file to the caller
and then it will call recvEvent() and print the event name. I've handled
signals also.

When I send SIGINT to my program (Perl), the signal handler is called and I
can see the print output. But in the same time,  I received
SERVER_DISCONNECTED from freeswitch as event.

I don't know why I received SERVER_DISCONNECTED from freeswitch. Is it
because, the recvEvent() from perl internally  calls the recvevent function
in the Esl.c and when it waits to receive the information from socket, the
signal occurred???

Please clarify me!!

Here is my program
require ESL;
use IO::Socket::INET;
use Data::Dumper;

my $ip = "192.168.1.222";
my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort => '8447',
Proto => 'tcp',  Listen => 1,  Reuse => 1 );
die "Could not create socket: $!\n" unless $sock;
&register_Signals();

for(;;) {
    my $new_sock = $sock->accept();
    next if (not defined ($new_sock));
    my $pid = fork();
    if ($pid) {
        close($new_sock);
        next;
    }
    print "CHILD PID: $$\n";
    my $host = $new_sock->sockhost();
    my $fd = fileno($new_sock);

    my $con = new ESL::ESLconnection($fd);
    my $info = $con->getInfo();

    my $uuid = $info->getHeader("unique-id");

    printf "Connected call %s, from %s\n", $uuid,
$info->getHeader("caller-caller-id-number");
    my $r=$con->execute("answer");
    print Dumper $r;
    $con->events("plain","all");
    my
$re=$con->execute("playback","/usr/local/freeswitch1/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav");

    while($con->connected()) {
        my $e = $con->recvEvent();

        if ($e) {
            my $name = $e->getHeader("event-name");
            print "EVENT [$name]\n";
            if ($name eq "DTMF") {
                my $digit = $e->getHeader("dtmf-digit");
                print "$digit\n";
            }
        }
    }
    close($new_sock);
}
sub register_Signals() {
    foreach ( keys %SIG ) {
        $SIG{$_} = 'sig_Handler';
    }
}

sub sig_Handler() {
    my $handle=$_[0];
    if($handle eq "INT") {
        print "$$: SIGNAL SIG$handle is generated\n";
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100113/aab5c72a/attachment-0002.html 


More information about the FreeSWITCH-users mailing list