The code below complies correctly. Now I open 2 terminals ... one for executing the code using gcc and the other with asterisk -r command.<br>When i execute the code, in the asterisk command link it shows Connect attempt from '<a href="http://192.168.0.150">192.168.0.150</a>' unable to authenticate. I have defined the username as admin and the secret as admin in manager.conf. Whereas if I use telnet <a href="http://192.168.0.150">192.168.0.150</a> 5038 I can connect correctly and in the asterisk commandline it shows Manager 'admin' logged on from <a href="http://192.168.0.150">192.168.0.150</a>.<br>
<br>Where am I going wrong in my code. Please let me know.<br><br>#include<stdio.h><br>
#include<netdb.h><br>
#include<unistd.h><br>
#include<string.h><br>
#include<arpa/inet.h><br>
#include<sys/types.h><br>
#include<sys/socket.h><br>
#include<netinet/in.h><br>
<br>
#define MAX_MSG_SIZE 512<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>
<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>
printf("\nCreated socket ...");<br>
<br>
bind(sd,(struct sockaddr *) &clientaddr, sizeof(clientaddr));<br>
printf("\nBinding successful ...");<br>
<br>
connect(sd,(struct sockaddr *) &serveraddr, sizeof(serveraddr));<br>
printf("\nConnected ...");<br>
<br>
*msg=(char)"Action: Login\r\nUsername: admin\r\nSecret: admin\r\nActionID: 1\r\n\r\n";<br>
send(sd,msg,strlen(msg)+1,0);<br>
close(sd);<br>
<br>
return(1);<br>
}<br>