|
-
April 18th, 2011, 05:54 AM
#1
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|