Problem with ethernet shield

I’ve created a simple webserver:

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 151 };
byte gateway[] = { 10, 0, 0, 1 };
byte netmask[] = { 255, 255, 255, 0 };

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
  Serial.begin(9600);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    Serial.println("Client connesso!\n");
    
    //server.write("HTTP/1.1 200 OK");
    //server.write("Content-Type: text/html");
    //client.println();  
    //server.write("<center><h1>It Works!</h1></center>
");  
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println();  
    client.println("<center><h1>It Works!</h1></center>
");  
    
    // give the web browser time to receive the data
    delay(10);
    // close the connection:
    client.stop();
  }
}

When i visit 10.0.0.151 address from my web browser the output is showed in the image attached.
Is it a problem with my ethshield? The ‘L’ led has also a strange light, it is not turned off but also not completely turned on.
Thank you very much.

Is it a problem with my ethshield?

No. It is a problem with the data you are sending to the client. That data does not represent either a proper html page or a proper packet.

Proper html pages start with and end with , and proper packets end with a blank line (just the carriage return/line feed output by println()).

PaulS:

Is it a problem with my ethshield?

No. It is a problem with the data you are sending to the client. That data does not represent either a proper html page or a proper packet.

Proper html pages start with and end with , and proper packets end with a blank line (just the carriage return/line feed output by println()).

It’s not a problem with html page or packet, i’ve tried also with and with println at the end.

I’ve tried also with ChatServer and if I telnet on the chatserver output will be a lot of random chars and it will go on loop.
Someone who can help me?

It’s not a problem with html page or packet, i’ve tried also with and with println at the end.

Code?

What browser are you using?

PaulS:

It’s not a problem with html page or packet, i’ve tried also with and with println at the end.

Code?

What browser are you using?

the code is the same with:

client.println("<html><body><center><h1>It Works!</h1></center>
</body></html>");
client.println();

I use Firefox (iceweasel), but the problem occurs also with telnet using ChatServer example.

I modified your code below to use with my router and it works with IE7 with no issues.

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
byte gateway[] = { 192, 168, 1, 1 };
byte netmask[] = { 255, 255, 255, 0 };

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(84);

void setup()
{
  Serial.begin(9600);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    Serial.println("Client connesso!\n");
    
    //server.write("HTTP/1.1 200 OK");
    //server.write("Content-Type: text/html");
    //client.println();  
    //server.write("<center><h1>It Works!</h1></center>
");  
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println();  
    client.println("<center><h1>It Works!</h1></center>
");  
    
    // give the web browser time to receive the data
    delay(10);
    // close the connection:
    client.stop();
  }
}