@@ -36,8 +36,10 @@ void setup()
36
36
37
37
void loop ()
38
38
{
39
- const uint16_t port = 80 ;
40
- const char * host = " 192.168.1.1" ; // ip or dns
39
+ // const uint16_t port = 80;
40
+ // const char * host = "192.168.1.1"; // ip or dns
41
+ const uint16_t port = 1337 ;
42
+ const char * host = " 192.168.1.10" ; // ip or dns
41
43
42
44
Serial.print (" Connecting to " );
43
45
Serial.println (host);
@@ -53,16 +55,33 @@ void loop()
53
55
}
54
56
55
57
// This will send a request to the server
56
- client.print (" Send this data to the server" );
57
-
58
+ // uncomment this line to send an arbitrary string to the server
59
+ // client.print("Send this data to the server");
60
+ // uncomment this line to send a basic document request to the server
61
+ client.print (" GET /index.html HTTP/1.1\n\n " );
62
+
63
+ int maxloops = 0 ;
64
+
65
+ // wait for the server's reply to become available
66
+ while (!client.available () && maxloops < 1000 )
67
+ {
68
+ maxloops++;
69
+ delay (1 ); // delay 1 msec
70
+ }
71
+ if (client.available () > 0 )
72
+ {
58
73
// read back one line from the server
59
74
String line = client.readStringUntil (' \r ' );
60
- client.println (line);
75
+ Serial.println (line);
76
+ }
77
+ else
78
+ {
79
+ Serial.println (" client.available() timed out " );
80
+ }
61
81
62
82
Serial.println (" Closing connection." );
63
83
client.stop ();
64
84
65
85
Serial.println (" Waiting 5 seconds before restarting..." );
66
86
delay (5000 );
67
87
}
68
-
0 commit comments