please help me to find something wrong with the following code!

0 views
Skip to first unread message

dragon

unread,
Dec 7, 2006, 2:54:33 AM12/7/06
to Linux小抽屉
=======================================================
...
struct hostent *host;
struct sockaddr_in addr;

...

bzero(&addr, sizeof(struct sockaddr_in));
if( inet_aton("192.168.4.1", &addr.sin_addr) != 0 ){
host = gethostbyaddr((char *)&addr.sin_addr, 4, AF_INET);
}
if( host == NULL){
fprintf(stderr, "Gethostbyaddr error: %s\n", hstrerror(
h_errno ) );
}

...
====================================================
It can be cpmpiled successfully, but it always get the incorrect
information: "Unknown host" after running.
who can help me?

国宝

unread,
Dec 7, 2006, 4:41:39 AM12/7/06
to Linux小抽屉
大哥,你就给这么短的代码片断啊?呵呵,最好整个粘贴上来吧?比较好一点!
Reply all
Reply to author
Forward
0 new messages