[asterisk-dev] An error from AMI

Michael Henderson mdfromusa at gmail.com
Sat Mar 1 11:34:50 CST 2008


Hi,

I am writing a C code which will help will help me to connect with AMI and
query from it to obtain furthur results. The code that I am using is as
given below:

sd = socket(AF_INET, SOCK_STREAM, 0);
bind(sd,(struct sockaddr *) &cliaddr, sizeof(cliaddr));
connect(sd,(struct sockaddr *) &seraddr, sizeof(seraddr));
strcpy(msg,"Action: Login\r\nUsername: md\r\nSecret: md5\r\n\r\n");
send(sd,msg,strlen(msg)+1,0);
recv(sd,rec,sizeof rec,0);
printf("%s",rec);
strcpy(msg,"Action: Ping\r\n\r\n");
send(sd,msg,strlen(msg)+1,0);
recv(sd,rec,sizeof rec,0);
printf("%s",rec);

On executing the code, in the asterisk console I am getting the messege that
md is logging from xxx.xxx.xxx.xxx. But, the problem that I am facing is
after executing this code of authentication when I send action: ping to AMI
using the same socket descriptor then I am receiving an error, that is I get
Response: Error, there is no action.

What should I do to make it happen. Please dont reffer me libami cause I
dont want to use any library to access AMI. I want to use just C code to
access AMI.

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20080301/f63b4f8e/attachment.htm 


More information about the asterisk-dev mailing list