EasyManua.ls Logo

Espressif ESP8266 - Page 27

Espressif ESP8266
51 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
30
31
Serial.print("connecting to ");
32
Serial.println(host);
33
34
//
Use WiFiClient class to create TCP connections
35
WiFiClient client;
36
const int httpPort = 80;
37
if (!client.connect(host, httpPort)) {
38
Serial.println("connection failed");
39
return;
40
}
41
42
//
We now create a URI for the request
43
String url = "/guide/";
44
45
Serial.print("Requesting URL: ");
46
Serial.println(url);
47
48
//
This will send the request to the server
49
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
50
"Host: " + host + "\r\n" +
51
"Connection: close\r\n\r\n");
52
53
unsigned long timeout = millis();
54
while (client.available() == 0) {
55
if (millis()
-
timeout > 5000) {
56
Serial.println(">>> Client Timeout !");
57
client.stop();
58
return;
59
}
60
}
61
62
//
Read all the lines of the reply from server and print them to Serial
63
while(client.available()){

Other manuals for Espressif ESP8266

Related product manuals