Try this one!


> -------------------------------
> #include <stdio.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <sys/ioctl.h>
> #include <net/if.h>
> #include <netinet/in.h>
> 
> main(int argc, char *argv[])
> {
>   struct ifreq ifr;
>   struct sockaddr_in isa;
>   int sockfd;
>   
>   sockfd=socket(AF_INET, SOCK_RAW, 255);
> /* Just try to uncomment the following line */
>   bzero(&ifr, sizeof(ifr.ifr_name));
                       ^^^^^^^^^^^^
>   strcpy(ifr.ifr_name, argv[1]);
>   if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) {
>     perror("ioctl()");
>     exit(0);
>   }
>   bcopy(&ifr.ifr_addr, &isa, sizeof(ifr.ifr_addr));
                                      ^^^^^^^^^^^^
>   printf("Address: %s\n", inet_ntoa(isa.sin_addr.s_addr));
>   close(sockfd);
> }
> -----------------


David Ross

[EMAIL PROTECTED]
Toad Technologies

"I'll be good! I will, I will !"
 

Reply via email to