Can't get even the simple webserver working after move to IDE 1.0.1

Hi all,
I'm a bit stumped. I've tried the following simple code:

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

// network configuration.  gateway and subnet are optional.

 // the media access control (ethernet hardware) address for the shield:
byte mac[] =        { 0x90, 0xA6, 0xEA, 0xA0, 0x13, 0xA7 };
//the IP address for the shield:
byte ip[] = { 192, 168, 1, 111};    
// the router's gateway address:
byte gateway[] = { 192,168,1,1 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };

EthernetServer server = EthernetServer(51);

void setup()
{
  Serial.begin(9600);
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);

  // start listening for clients
  server.begin();
}

void oldloop()
{
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client == true) {
    // read bytes from the incoming client and write them back
    // to any clients connected to the server:
    server.write(client.read());
  }
}


void loop(){
  int i;

  //Serial.println(Ethernet.localIP());
  // Create a client connection for the PUBLIC Web Server
  EthernetClient cl = server.available();
  if (cl == true) {  
    Serial.println("got a client...");
    while (cl.connected()) {
      if (cl.available()) {
        Serial.println("got something avail...");
        char c = cl.read();

        //if HTTP request has ended
        if (c == '\n') {

          cl.println("HTTP/1.1 200 OK");
          cl.println("Content-Type: text/html");
          cl.println();
          cl.println();

          cl.println("<html>");
          cl.println("<HEAD>");
          cl.println("<TITLE>My Test Page</TITLE>");
          cl.println("<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">");
          cl.println("<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">");
          cl.println("</HEAD>");
          cl.println("<body bgcolor=\"#EFF5D5\">");
          cl.println("<h1><u><b>My Test Page</b></u></h1>");

          cl.println("</body>");
          cl.println("</html>");

          cl.flush();
          cl.stop();
          break;
        }
      }
    }

    cl.flush();
    cl.stop();
  } else {
    Serial.println("failed to get client...");
  }

  delay(1000);
} // loop

And all it does is spit out the failure message over and over that it can't get a client on the server. What I've tested is pinging the IP address in a dos prompt like this:

ping 192.168.1.111

and this works. So I know my ethernet shield is alive. If I remove the ethernet cable, then ping stops working. I'm using an ATMEGA2560 board, but I know it's flashing right since the "blink" test script works. Also, this whole same hardware did a fine web server prior to me upgrading to 1.0.1. I was on pre 1.0.0 before when it worked.

I am using as you can see the new api's like EthernetServer and EthernetClient. I'm quite confused why my server won't work now. Anyone have ideas?

Or does anyone have a simple web page sketch that works for them on 1.0.1 I can try out on my board?

  Ethernet.begin(mac, ip, gateway, subnet);

Starting with Arduino 1.0 you have to put a DNS Server address between 'gateway' and 'subnet'.

Thanks for the suggestion. So I figured out my issue. This code above (even without dns) does actually work. I think either some dangling wires (previous connections that I disconnected from inputs to bring the board to my PC to program) were somehow causing issues. Also, I'm suspecting that powering it over USB alone is somehow not 100% working. Anyway, just wanted to update everyone that I got a web page serving now. Now to get the SD card working, which is also still giving me pains. :frowning:

If you are having pains getting the SD card to initialize correctly, insure you disable the w5100 before calling SD.begin().

void setup()
{
  Serial.begin(9600);

  // disable the w5100 while you set up the SD
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);

  // SD.begin() returns with its SS (digital pin 4) HIGH (disabled)
  if(SD.begin(4) == 0) Serial.println("SD fail");
  else Serial.println("SD ok");

  // now set up the ethernet stuff
}