Ethernat getting started question

I' using a Roboduino shield on a Duemilanove. I believe this is a referance design using the WZ5100.

I want to access a web page by URL not IP address. How do I do this ? I'm using the std library #including Ethernet.h, IDE = Arduino 0017 and OS is Ubuntu 9.04.

I have searched to forum but all the examples I can find all use the google IP address not a URL.

Any ideas ?

Matt B

You’ll want to search for the third-party library that handles DNS (and probably DHCP for good measure).

–Philip;

May not be the best of help, but if you are using a static IP and only needing access on a few computers you could change the host file on the computer to point to that address. Then again if that were the case you could also bookmark the IP so I'm guessing that's not what you want.

I'm using the alternative Ethernet library that sile introduced in this thread to access a site hosted by godaddy.com that doesn't have a guaranteed static address.

I added a function called "setserver" to Client.h:

  void setserver(uint8_t *ip, uint16_t port);

and Client.cpp:

// Change the server IPA and port after the class has been instantiated
void Client::setserver(uint8_t *ip, uint16_t port) {
  _ip = ip;
  _port = port;
}

To change the server address "on the fly", I do a DNS lookup and update the (statically allocated) instance of Client in a subroutine that's called as part of the "initialize the Ethernet" code:

      DnsClass go_dns;
      byte dns_ipa[] = { 216, 69, 185, 29 }; // godaddy.com DNS
    int results;

          // Do DNS Lookup.
        //  Host name is stored in PROGMEM,  and copied to a shared
        // utility buffer called "line_buff",  to save RAM 
    strcpy_P(line_buff, server_name);
    go_dns.init(line_buff, dns_ipa);
    go_dns.resolve();

    while(!(results = go_dns.finished())) ;  //wait for DNS to resolve the name

    if (results == 1)
            {
            go_dns.getIP(server_ipa);  //buffer now contains the IP address for our server
            post_client.setserver(server_ipa, 80);
            }

(Sorry about the funky indentation: I use tab stops every 4 columns for C and C++, but the forum software seems to use 8)

Be sure to check for "results == 1", since Dns::finished() also returns a (different) non-zero result if the lookup fails.

Ran