I'm using the example ethernet web server code and I'm trying to define the web client "Client client = server.available();" which is currently located in a loop as a global variable.
I have tried:
Client client; // Defining client outside of a class (globally)
loop(){
client = server.available();
}
But returns the error:
no matching function for call to 'Client::Client()'
/Applications/Arduino.app/Contents/Resources/Java/hardware/libraries/Ethernet/Client.h:6: note: Client::Client(const Client&)
Would anyone know how to define client globally but still keep updating in a loop. So that I can do some processing on the client in other classes/functions.
This is the Arduino Ethernet Web Server example code (stripped down) for example.
/*
* Web Server
*
*/
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
Server server(80);
void setup()
{
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
}
}
}
}