unknown server error

Luciano Rocha strange at nsk.no-ip.org
Thu Sep 6 13:33:01 UTC 2007


On Thu, Sep 06, 2007 at 12:36:33PM +0100, nita lohia wrote:
> Hello
>    
>   here is full discription:
>    
>   #include<stdio.h>
> #include<netdb.h>
Also include <unistd.h> for gethostname().

> int main()
> {
>  struct hostenv *hp;
This is struct hostent, not hostenv.

>  char host[120];
>  if(gethostname(host,sizeof(host))<0)
>   return -1;
>  printf("host:%s\n",host);
>  if(hp=gethostbyname(host)==NULL)
Group this correctly:
if((hp=gethostbyname(host))==NULL)

>   {
>    printf("%s",hstrerror(h_errno));

This is obsolete, use perror(host) directly;

>    return -1;
>   }
>  printf("hello");
Don't forget \n.

Also, to see the result:
printf("host %s: %s\n", host,
  inet_ntoa(*(struct in_addr *)hp->h_addr_list[0]));

(with include of: <sys/socket.h> <netinet/in.h> <arpa/inet.h>


>  return 0;
>   }
>   O/p : 
> host:SetuVFX88L
> Unknown server error

Here, with the changes:
host:bit.office.eurotux.com
hello
host bit.office.eurotux.com: 10.10.10.8


>    
>   files
>    
>   /etc/hosts
> 127.0.0.1 localhost.localdomain localhost
> 192.168.1.104 SetuVFX88L

Are you using glibc, and included the needed libraries for name
resolve? libnss_*

-- 
lfr
0/0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070906/34c62e98/attachment-0002.pgp 


More information about the busybox mailing list