Upload error, Arduino Ethernet ("Client client"?)

I want to try the "Pin Control Over the Internet – Arduino + Ethernet" sketch (link below), but I get this error: "cannot declare parameter 'client' to be of abstract type 'Client'".

The rest of the error:

sketch_dec25b:1: error: cannot declare parameter 'client' to be of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   because the following virtual functions are pure within 'Client':
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:12: note: 	virtual size_t Client::write(uint8_t)
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:13: note: 	virtual size_t Client::write(const uint8_t*, size_t)
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:14: note: 	virtual int Client::available()
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:15: note: 	virtual int Client::read()
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:17: note: 	virtual int Client::peek()
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:18: note: 	virtual void Client::flush()
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:10: note: 	virtual int Client::connect(IPAddress, uint16_t)
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:11: note: 	virtual int Client::connect(const char*, uint16_t)
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:16: note: 	virtual int Client::read(uint8_t*, size_t)
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:19: note: 	virtual void Client::stop()
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:20: note: 	virtual uint8_t Client::connected()
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:21: note: 	virtual Client::operator bool()
sketch_dec25b:16: error: cannot allocate an object of abstract type 'Server'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Server.h:4: note:   because the following virtual functions are pure within 'Server':
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: note: 	virtual size_t Print::write(uint8_t)
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Server.h:6: note: 	virtual void Server::begin()
sketch_dec25b:16: error: cannot declare variable 'server' to be of abstract type 'Server'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Server.h:4: note:   since type 'Server' has pure virtual functions
sketch_dec25b.cpp: In function 'void checkForClient()':
sketch_dec25b:44: error: 'class Server' has no member named 'available'
sketch_dec25b:44: error: cannot declare variable 'client' to be of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:74: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:78: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:82: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:86: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:90: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:94: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:98: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b:102: error: cannot allocate an object of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions
sketch_dec25b.cpp: At global scope:
sketch_dec25b:126: error: cannot declare parameter 'client' to be of abstract type 'Client'
C:\Users\Anders\Downloads\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Client.h:7: note:   since type 'Client' has pure virtual functions

Link to the article with the code: http://bildr.org/2011/06/arduino-ethernet-pin-control/

This is the exact code I'm using (had to use pastebin because of "The message exceeds the maximum allowed length (9500 characters)":

I tried to upload a simular code, with the same error message. So apparently there's a problem with "client".

Please help me guys, I really want to be able to control the output pins over internet! :slight_smile:

I'm pretty sure it has something to do with the two lines I marked red and bold below. When i changed "Client client" to "Client test", I got the same error message, but the first "client" was replaced with "test", but the second "Client" was still there. When I changed "Client client" to "Test client", I got a different error message.

#include <Ethernet.h>
#include <SPI.h>
boolean reading = false;

////////////////////////////////////////////////////////////////////////
//CONFIGURE
////////////////////////////////////////////////////////////////////////
byte ip[] = { 192, 168, 1, 55 }; //ip address to assign the arduino
byte gateway[] = { 192, 168, 1, 1 }; //ip address of the gatewa or router

//Rarly need to change this
byte subnet[] = { 255, 255, 255, 0 };

// if need to change the MAC address (Very Rare)
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x72, 0x30 };

Server server = Server(55); //port 80
////////////////////////////////////////////////////////////////////////

void setup(){
//Pins 10,11,12 & 13 are used by the ethernet shield

pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);

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

void loop(){

// listen for incoming clients, and process qequest.
checkForClient();

}

void checkForClient(){

** Client client = server.available();**

if (client) {

// an http request ends with a blank line
boolean currentLineIsBlank = true;
boolean sentHeader = false;

while (client.connected()) {
if (client.available()) {

if(!sentHeader){
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
sentHeader = true;
}

char c = client.read();

if(reading && c == ' ') reading = false;
if(c == '?') reading = true; //found the ?, begin reading the info

if(reading){
Serial.print(c);

switch (c) {
case '2':
//add code here to trigger on 2
triggerPin(2, client);
break;
case '3':
//add code here to trigger on 3
triggerPin(3, client);
break;
case '4':
//add code here to trigger on 4
triggerPin(4, client);
break;
case '5':
//add code here to trigger on 5
triggerPin(5, client);
break;
case '6':
//add code here to trigger on 6
triggerPin(6, client);
break;
case '7':
//add code here to trigger on 7
triggerPin(7, client);
break;
case '8':
//add code here to trigger on 8
triggerPin(8, client);
break;
case '9':
//add code here to trigger on 9
triggerPin(9, client);
break;
}

}

if (c == '\n' && currentLineIsBlank) break;

if (c == '\n') {
currentLineIsBlank = true;
}else if (c != '\r') {
currentLineIsBlank = false;
}

}
}

delay(1); // give the web browser time to receive the data
client.stop(); // close the connection:

}

}

void triggerPin(int pin, Client client){
//blink a pin - Client needed just for HTML output purposes.
client.print("Turning on pin ");
client.println(pin);
client.print("
");

digitalWrite(pin, HIGH);
delay(25);
digitalWrite(pin, LOW);
delay(25);
}

Some web server code you can experiment with.

//zoomkat 12-8-11
//simple button GET with iframe code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html 
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 

//////////////////////

void setup(){

  pinMode(4, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

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

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

          //now output HTML data header
             if(readString.indexOf('?') >=0) { //don't send new page
               client.println("HTTP/1.1 204 Zoomkat");
               client.println();
               client.println();  
             }
             else {
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Zoomkat's simple Arduino button</H1>");
          
          client.println("<a href=\"/?on\" target=\"inlineframe\">ON</a>"); 
          client.println("<a href=\"/?off\" target=\"inlineframe\">OFF</a>"); 

          //client.println("<IFRAME name=inlineframe src=\"res://D:/WINDOWS/dnserror.htm\" width=1 height=1\">");
          client.println("<IFRAME name=inlineframe style=\"display:none\" >");          
          client.println("</IFRAME>");

          client.println("</BODY>");
          client.println("</HTML>");
             }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

zoomkat:
Some web server code you can experiment with.

//zoomkat 12-8-11

//simple button GET with iframe code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString;

//////////////////////

void setup(){

pinMode(4, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

//enable serial data print
  Serial.begin(9600);
  Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

//read char by char HTTP request
        if (readString.length() < 100) {

//store characters to string
          readString += c;
          //Serial.print(c);
        }

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

///////////////
          Serial.println(readString); //print to serial monitor for debuging

//now output HTML data header
             if(readString.indexOf('?') >=0) { //don't send new page
               client.println("HTTP/1.1 204 Zoomkat");
               client.println();
               client.println(); 
             }
             else {
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();

client.println("");
          client.println("");
          client.println("Arduino GET test page");
          client.println("");
          client.println("");

client.println("

Zoomkat's simple Arduino button

");
         
          client.println("<a href="/?on" target="inlineframe">ON");
          client.println("<a href="/?off" target="inlineframe">OFF");

//client.println("<IFRAME name=inlineframe src="res://D:/WINDOWS/dnserror.htm" width=1 height=1">");
          client.println("<IFRAME name=inlineframe style="display:none" >");         
          client.println("");

client.println("");
          client.println("");
             }

delay(1);
          //stopping client
          client.stop();

///////////////////// control arduino pin
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

}
      }
    }
  }
}

Thank you so much! I've been searching for a simple code like that for hours :slight_smile:

I want to try the "Pin Control Over the Internet – Arduino + Ethernet" sketch (link below), but I get this error: "cannot declare parameter 'client' to be of abstract type 'Client'".

It looks like the Server and Client names changed after some examples were written. And it seems that SPI.h needs to be included, in many cases.

At the top, make sure you have one of these:

#include <SPI.h>

Then substitute the "Server" and "Client" with "EthernetServer" and "EthernetClient" everywhere you see 'em. That's just for the uppercase versions of those, the lowercase ones stay the same. I was having trouble running the basic ethernet server example at Ethernet - Arduino Reference, and these changes fixed that. My updated ethernet server example code, btw, has these two updated lines:

EthernetServer server = EthernetServer(23);
EthernetClient client = server.available();

HTH! -Gabe