Hi, I’m having trouble getting the TCPClient to connect to a server defined by domain name, as opposed to the ip address. I’m basically copying the example from the docs, but substituting in the Google domain name I am unable to connect. Anyone got any ideas? Thanks! Code below:
TCPClient client;
//byte server[] = { 74, 125, 224, 72 }; // Google
void setup()
{
pinMode(D7,OUTPUT); // Turn on the D7 led so we know it's time
digitalWrite(D7,HIGH); // to open the Serial Terminal.
Serial.begin(9600);
while(!Serial.available()) // Wait here until the user presses ENTER
SPARK_WLAN_Loop();
Serial.println("connecting...");
digitalWrite(D7,LOW);
if (client.connect("www.gooogle.com", 80))
{
Serial.println("connected");
client.println("GET /search?q=unicorn HTTP/1.0");
client.println();
}
else
{
Serial.println("connection failed");
}
}
void loop()
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}