Server class

Hi I was wondering which Server should I be using to create an instance to create a server to listen for udp transfer? What is the difference between them?

this one

// telnet defaults to port 23
Server server = Server(23);

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

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

}

void loop()
{
  // if an incoming client connects, there will be bytes available to read:
  Client 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());
  }
}

or this one

EthernetServer server = EthernetServer(23);

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

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

void loop()
{
   // 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());
   }
}

Thanks Don

Don,

I don't have ethernet shield but I have wifi shields. My understanding is that Server class is purely virtual and meant for other classes to inherit from, such as Ethernetserver or Wifiserver, which have functions that work with the specific hardware. So I think you should use the second code. Did you get the first code from somewhere? Just curious.

Whether to use Server or EthernetServer depends on which version of the IDE you are using. There is no one answer.

PaulS:
Whether to use Server or EthernetServer depends on which version of the IDE you are using. There is no one answer.

OK, my remarks were based on Arduino IDE 1.0.X I didn't use any networking in 002X.

Thanks guys I'm working with 1.0.x also. Don