Skip to content

Commit 3baa0ce

Browse files
committed
Merge branch 'master' of github.com:arduino/Arduino
2 parents 7fcba37 + ffb8a55 commit 3baa0ce

File tree

4 files changed

+7
-36
lines changed

4 files changed

+7
-36
lines changed

hardware/arduino/cores/arduino/Client.h

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ class Client : public Stream {
1919
virtual void stop() = 0;
2020
virtual uint8_t connected() = 0;
2121
virtual operator bool() = 0;
22-
virtual uint16_t localPort() = 0;
23-
virtual IPAddress remoteIP() = 0;
24-
virtual uint16_t remotePort() = 0;
2522
protected:
2623
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
2724
};

libraries/Ethernet/EthernetClient.cpp

-17
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,3 @@ EthernetClient::operator bool() {
167167
bool EthernetClient::operator==(const EthernetClient& rhs) {
168168
return _sock == rhs._sock && _sock != MAX_SOCK_NUM && rhs._sock != MAX_SOCK_NUM;
169169
}
170-
171-
uint16_t EthernetClient::localPort() {
172-
if (_sock == MAX_SOCK_NUM) return 0;
173-
return W5100.readSnPORT(_sock);
174-
}
175-
176-
IPAddress EthernetClient::remoteIP() {
177-
if (_sock == MAX_SOCK_NUM) return IPAddress(0,0,0,0);
178-
uint32_t _destaddress;
179-
W5100.readSnDIPR(_sock,(uint8_t*) &_destaddress);
180-
return IPAddress(_destaddress);
181-
}
182-
183-
uint16_t EthernetClient::remotePort() {
184-
if (_sock == MAX_SOCK_NUM) return 0;
185-
return W5100.readSnDPORT(_sock);
186-
}

libraries/Ethernet/EthernetClient.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class EthernetClient : public Client {
2525
virtual uint8_t connected();
2626
virtual operator bool();
2727
virtual bool operator==(const EthernetClient&);
28-
virtual uint16_t localPort();
29-
virtual IPAddress remoteIP();
30-
virtual uint16_t remotePort();
28+
virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
3129

3230
friend class EthernetServer;
3331

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)