1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

update AdvancedChatServer.ino, add operator!=

This commit is contained in:
ntruchsess 2013-12-06 23:19:19 +01:00
parent fbdf3a18ee
commit 29954567e7
2 changed files with 7 additions and 13 deletions

View File

@ -25,6 +25,7 @@ public:
virtual uint8_t connected();
virtual operator bool();
virtual bool operator==(const EthernetClient&);
virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
friend class EthernetServer;

View File

@ -75,22 +75,15 @@ void loop() {
for (byte i=0;i<4;i++) {
if (!clients[i] && clients[i]!=client) {
clients[i] = client;
// clead out the input buffer:
client.flush();
Serial.println("We have a new client");
client.print("Hello, client number: ");
client.print(i);
client.println();
break;
}
}
// clead out the input buffer:
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
client.print("my IP: ");
client.println(Ethernet.localIP());
client.print("my port: ");
client.println(client.localPort());
client.print("your IP: ");
client.println(client.remoteIP());
client.print("your port: ");
client.println(client.remotePort());
}
if (client.available() > 0) {