Hi,<br><br>>Michael Henderson wrote:<br>
> *msg=(char)"Action: Login\r\nUsername: admin\r\nSecret:<br>
> admin\r\nActionID: 1\r\n\r\n";<br>
<br>>>
Russell Bryant wrote:<br>>>change this to ...<br>
>><br>>>strncpy(msg, "Action: blahblahblah\r\n\r\n", sizeof(msg) - 1)<br>
<br><br>I have changed the code as you said with strcpy and now I can connect with Asterisk Manager Interface. I can correctly see that admin is trying to login in from <a href="http://192.168.0.150">192.168.0.150</a>. The problem that I am facing now is after authentication if I try to ping the server the response I get is Response: Error and states that there is no action.<br>
<br>Here is my code:<br><br>#define MAX_MSG_SIZE 3072<br>
#define SERVER_ADDRESS "<a href="http://192.168.0.150/" target="_blank">192.168.0.150</a>"<br>
#define CLIENT_ADDRESS "<a href="http://192.168.0.150/" target="_blank">192.168.0.150</a>"<br>
#define SERVER_PORT 5038<br>
#define CLIENT_PORT 5100<br>
<br>
int main()<br>
{<br>
int sd;<br>
struct sockaddr_in serveraddr, clientaddr;<br>
char msg[MAX_MSG_SIZE];<br> char resp[MAX_MSG_SIZE];<br>
<br>
bzero((char *) &serveraddr, sizeof(serveraddr));<br>
serveraddr.sin_family = AF_INET;<br>
serveraddr.sin_addr.s_addr = inet_addr(SERVER_ADDRESS);<br>
serveraddr.sin_port = htons(SERVER_PORT);<br>
<br>
bzero((char *) &clientaddr, sizeof(clientaddr));<br>
clientaddr.sin_family = AF_INET;<br>
clientaddr.sin_addr.s_addr = INADDR_ANY;<br>
clientaddr.sin_port = htons(CLIENT_PORT);<br>
<br>
sd = socket(AF_INET, SOCK_STREAM, 0);<br>
<br>
bind(sd,(struct sockaddr *) &clientaddr, sizeof(clientaddr));<br>
<br>
connect(sd,(struct sockaddr *) &serveraddr, sizeof(serveraddr));<br><br>strcpy(msg,"Action: Login\r\nUsername: admin\r\nSecret: admin\r\n\r\n");<br>send(sd,msg,strlen(msg)+1,0);<br>recv(sd,resp, sizeof resp,0);<br>
printf("%s",resp);<br>strcpy(resp," ");<br><br>sleep(1);<br><br>strcpy(msg,"Action: Ping\r\n\r\n");<br>send(sd,msg,strlen(msg)+1,0);<br>recv(sd,resp,sizeof resp,0);<br>printf("%s",resp) // In here it prints Response: Error.<br>
close(sd);<br>
<br>return(1);<br>
}<br><br>Now why is it so ? It should return Response: Pong as I am still connected with Asterisk Manager.<br><br>Thank you.<br>