Hi everyone
Thank you very much. For your post. With your help I was able to correct the
code.
The problem was in the function that was called by the main function.
[...]
if ( get_address(&myip) != 0)
[...]
int get_address(char **address)
{
int sock_fd = socket( AF_INET , SOCK_DGRAM , 0 );
if( sock_fd == -1 ) { printf("Error: creating socket.\n"); return(1); }
struct ifreq ifr;
strcpy( ifr.ifr_name , "eth1" );
if( ioctl( sock_fd , SIOCGIFADDR , &ifr ) == -1 ) { printf("problems
with ioctl.\n"); return(1); }
--> /* Now the next statement is wrong. With char * = char * the address
of the pointer changes */
--> *address = inet_ntoa( ((struct sockaddr_in *)
(&ifr.ifr_addr))->sin_addr);
--> /* One has to use strcpy instead so that it looks like */
--> strcpy(*address, inet_ntoa( ((struct sockaddr_in *)
(&ifr.ifr_addr))->sin_addr));
--> /* This does work now. */
close( sock_fd );
return 0;
}
Thank you very much again. Willem
--
View this message in context:
http://www.nabble.com/Linux-signal-Programming-freeing-memory-on-cleanup-tp25391730p25399384.html
Sent from the C-prog mailing list archive at Nabble.com.