This stuff drives me mad today. While I thought to have a working version of TCP connect last week, it now suddenly stopped working and gives me a ‘NOTconnected’. I stripped it down to the lightweight version (below) - pointing to my local web server - giving me the same.
this call:
if (client.connected()) {
throws a false. http://10.0.1.4:8000 is def. up and reachable from the core.
Any thoughts ?
– snippet:
TCPClient client;
const char * serverName = "10.0.1.4";
void setup() {
Serial.begin(9600);
}
void loop() {
client.connect(serverName, 8000);
if (client.connected()) {
String GetURL = "GET /pushingbox?devid=";
Serial.println("Connected");
client.println("GET /pushingbox?devid= HTTP/1.0");
client.print("Host: ");
client.println("10.0.1.4");
client.println("Connection: close"); //just added
client.println();
client.flush();
delay(400);
client.stop();
}
else {
client.flush();
client.stop();
Serial.println("NOTconnected");
}
delay(5000);
}