Skip to content

Commit 2995456

Browse files
committed
update AdvancedChatServer.ino, add operator!=
1 parent fbdf3a1 commit 2995456

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

libraries/Ethernet/EthernetClient.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class EthernetClient : public Client {
2525
virtual uint8_t connected();
2626
virtual operator bool();
2727
virtual bool operator==(const EthernetClient&);
28+
virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
2829

2930
friend class EthernetServer;
3031

libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino

+6-13
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,15 @@ void loop() {
7575
for (byte i=0;i<4;i++) {
7676
if (!clients[i] && clients[i]!=client) {
7777
clients[i] = client;
78+
// clead out the input buffer:
79+
client.flush();
80+
Serial.println("We have a new client");
81+
client.print("Hello, client number: ");
82+
client.print(i);
83+
client.println();
7884
break;
7985
}
8086
}
81-
82-
// clead out the input buffer:
83-
client.flush();
84-
Serial.println("We have a new client");
85-
client.println("Hello, client!");
86-
client.print("my IP: ");
87-
client.println(Ethernet.localIP());
88-
client.print("my port: ");
89-
client.println(client.localPort());
90-
client.print("your IP: ");
91-
client.println(client.remoteIP());
92-
client.print("your port: ");
93-
client.println(client.remotePort());
9487
}
9588

9689
if (client.available() > 0) {

0 commit comments

Comments
 (0)