how to use WifiWebClient Sketch with Google IP address?

The sketch WIFI101 / WifiWebClient runs great (with Winc1500 breakout board).

It contains a google URL example but also says you can use google's IP address:

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "www.google.com"; // name address for Google (using DNS)

So I tried

char server[] = "(74,125,232,128)";

but it didn't work. Having searched the internet found this example from the Ethernet library in which the syntax seems the same but curly brackets are used:

So tried:

char server[] = "{74,125,232,128}";

but that didn't work either.

Also tried a number of other things (eg leaving off the brackets...) but no luck.

Anyone know how to make this sketch work with google's IP address instead of domain name?

Arduino has a special type called IPAddress that makes it easy to work with IP addresses. That is one of the allowed argument types of the WiFi101 library's connect function.

Change the line:

//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)

to:

IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)

Change the line:

char server[] = "www.google.com";    // name address for Google (using DNS)

to:

//char server[] = "www.google.com";    // name address for Google (using DNS)

That wasn't too difficult.

Thanks a lot!! :smiley:

Incidentally, further down the script the domain "google.com" comes up once again:

if (client.connect(server, 80)) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}

What is the role of the following line? Is it optional?

client.println("Host: www.google.com");

I think this explains it better than I could:
https://tools.ietf.org/html/rfc7230#section-5.4