It is easy in Unix. But I don't know how to convert in VxWorks?
/* unix
* compile: cc -o addr_conv addr_conv.c -lsocket -lnsl
* test : addr www.kaist.ac.kr
*/
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(int argc, char *argv[]) {
struct hostent *ptr_he;
struct in_addr in;
char *hname;
if(argc != 2) {
printf("Usage : %s hostname \n", argv[0]);
return -1;
}
hname = argv[1];
if((ptr_he = gethostbyname(hname)))
memcpy(&in.s_addr,ptr_he->h_addr_list[0], sizeof(in.s_addr));
printf("%s\'s IP address : %s\n", hname, inet_ntoa(in));
} else {
printf("gethostbyname error.\n");
}
}
bye
yann
Brendan Chung a écrit :
>
> How do I convert the IP address(numbers-and-dots notation) from Internet
> Host Address?
--
=====/= yann.cha...@temex.fr
= /=== Tekelec Temex
=/===== tel : +33 1 698 220 00
T E M E X 29 avenue de la Baltique
TELECOM 91953 Les Ulis cedex - FRANCE