passing IP Address as a parameter
Hi,
I am trying to pass the IP Address as a parameter instead of hard coding it, but I am ending with no connection.
The code is as follows:
char server_ip_address[16]; //globally declared
void put_address(char *ip_addr)
{
struct sockaddr_in ServAddr;
ServAddr.sin_addr.s_addr = inet_addr(ip_addr);
}
/*calling the put_address function */
udp_connect()
{
ServAddr.sin_family = AF_INET;
ServAddr.sin_len = sizeof(ServAddr);
put_address(&server_ip_address);
ServAddr.sin_port = 5060;
}
/*initializing the server_ip_address with IP Address in the main function*/
main()
{
scanf("%s", server_ip_address);
}
Any idea where I am making a mistake in my routine.
Thanks
Re: passing IP Address as a parameter
So when you run it through your debugger, what value gets passed?
Re: passing IP Address as a parameter
I can see that the variable is taking the value which is been given in the main function. But the problem is in my main function I am running other threads as well. Is that is the problem.
Re: passing IP Address as a parameter
got it working, was a small mistake in my code