help-cgicc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: (no subject)


From: Stephen F. Booth
Subject: RE: (no subject)
Date: Wed, 25 Oct 2000 08:49:18 -0500

> here is a program that i am wirting to access URL's from c program
> it is connecting to the IP address that I am giviing but not getting
> any data from it.
>
> It is also not working with URL's , that means i am not able to
> give "www.xxxxx" type of things here can any one please suggest any way
> for me any modification to be specific, I will be glad to accept any
> suggestion from you,

To accept www.xxx you need to translate the host into IPv4 numbers.
Something like


void
host_to_ip(char *dst, const char *src)
{
  struct hostent *hp;
  char **p;

  hp = gethostbyname(src);
  if(hp == NULL) {
    /* Host not found */
    dst = 0;
  }
  else {
    for(p = hp->h_addr_list; *p != 0; ++p) {
      struct in_addr in;

      memcpy(&in.s_addr, *p, sizeof(in.s_addr));
      /* dst needs to be at least 16 characters - "123.123.123.123\0" */
      strcpy(dst, inet_ntoa(in));
  }
}

Hope this helps.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]