Hi people
I am checking my arduino Ethernet to send data form sensors to my computer in localhost. In the future I ´ll send it to a mysql database via "GET" ..etc. , but, now, for demo mode I ´d make an example to read a file of my computer for check that all is ok.
I have created a file arduino.txt and I have it in localhost working fine . like this

also, I have made a copy-paste for example to connect via Ethernet to my computer, and I get conexion, but, I cannot read the file .
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x69, 0xDB }; //mac arduino
IPAddress ip(1192, 168, 1, 34); //my IP
IPAddress server(127, 0, 0, 1); //my localhost -
EthernetClient client;
void setup() {
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Fail DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("conecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /localhost/arduino.txt HTTP/1.0");
//client.println("GET localhost/arduino.txt HTTP/1.1");
client.println("Host: localhost");
client.println("Close");
client.println();
}
else {
Serial.println("fail");
}
}
//loop --------------------------------
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconecting.");
client.stop();
while(true);
}
}
The result in the console
conecting...
connected
HTTP/1.1 200 OK
Server: Virtual Web 0.9
Set-Cookie: SessionID=; path=/
Content-Type: text/html
Content-Length: 151
<html><head><meta HTTP-EQUIV="Pragma" CONTENT="no-cache"><script language='javascript'>parent.location="/login.htm"</script></head><body></body></html>
disconecting.
I have tried it client.println("GET localhost/arduino.txt HTTP/1.1"); with /localhost, with HTTP/1.0, but I don´t get read the file.
any idea ?
thks for all.