I want to use Ethernet shield to send/get data from my Apche server (localhost).
Ethernet(or Esp8266) ======(request.php by post method)==>>> server
Ethernet(or Esp8266) <<<=====(respond header and data)==== server
i send header to server to get data.
In my header:
If i use connection: close. This way seems ok.
But when i use connection: keep-alive. it can't connect or get any data till connection time out.
This is my header and way to send my data to server:
String result="";
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("POST myweb/getss.php HTTP/1.0");
client.println("Host: localhost");
client.println("Accept: *" "/" "*");
client.println("Content-Length: " + String(data.length()));
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Connection: keep-alive");
client.println();
client.print(data);
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
And disconnect:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.flush();
client.stop();
}
Please tell me what problems?