OK, that's good, thanks for the explanation.
But why, then, is this routine not working? I got this from zoomkat. My D-Link router is at 192.168.0.1. It is not connected to the internet. It worked before for reasons I never understood, that is, I could type "http://192.168.0.102:84" in the Firefox browser and see the Zoomkat meta-refresh page.
But now not. I changed the ip address to 192.168.0.102 in the code, and the code is below. It no longer works with IE or Firefox. All lights on and looks happy. "Link" LED is on. Something very basic is surely wrong, and this is exquisitely frustrating. Any help appreciated.
// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102:84/ in your brouser
#include <SPI.h>
#include <Ethernet.h>
int x=0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 102 };
Server server(84);
void setup()
{
// start the server
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
// listen for incoming clients
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
// see if HTTP request has ended with blank line
if (c == '\n') {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
//meta-refresh page every 2 seconds
x=x+1;
client.print("");
client.print("<meta http-equiv="refresh" content="2">");
client.print("Zoomkat's meta-refresh test");
client.print("");
client.print("page refresh number ");
client.println(x);
client.println("
");
client.println("
");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(analogRead(analogChannel));
client.println("
");
}
break;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}