mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Merge branch 'master' of github.com:arduino/Arduino
This commit is contained in:
@ -19,9 +19,6 @@ public:
|
|||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual uint8_t connected() = 0;
|
virtual uint8_t connected() = 0;
|
||||||
virtual operator bool() = 0;
|
virtual operator bool() = 0;
|
||||||
virtual uint16_t localPort() = 0;
|
|
||||||
virtual IPAddress remoteIP() = 0;
|
|
||||||
virtual uint16_t remotePort() = 0;
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
|
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
|
||||||
};
|
};
|
||||||
|
@ -167,20 +167,3 @@ EthernetClient::operator bool() {
|
|||||||
bool EthernetClient::operator==(const EthernetClient& rhs) {
|
bool EthernetClient::operator==(const EthernetClient& rhs) {
|
||||||
return _sock == rhs._sock && _sock != MAX_SOCK_NUM && rhs._sock != MAX_SOCK_NUM;
|
return _sock == rhs._sock && _sock != MAX_SOCK_NUM && rhs._sock != MAX_SOCK_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t EthernetClient::localPort() {
|
|
||||||
if (_sock == MAX_SOCK_NUM) return 0;
|
|
||||||
return W5100.readSnPORT(_sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress EthernetClient::remoteIP() {
|
|
||||||
if (_sock == MAX_SOCK_NUM) return IPAddress(0,0,0,0);
|
|
||||||
uint32_t _destaddress;
|
|
||||||
W5100.readSnDIPR(_sock,(uint8_t*) &_destaddress);
|
|
||||||
return IPAddress(_destaddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t EthernetClient::remotePort() {
|
|
||||||
if (_sock == MAX_SOCK_NUM) return 0;
|
|
||||||
return W5100.readSnDPORT(_sock);
|
|
||||||
}
|
|
||||||
|
@ -25,9 +25,7 @@ public:
|
|||||||
virtual uint8_t connected();
|
virtual uint8_t connected();
|
||||||
virtual operator bool();
|
virtual operator bool();
|
||||||
virtual bool operator==(const EthernetClient&);
|
virtual bool operator==(const EthernetClient&);
|
||||||
virtual uint16_t localPort();
|
virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
|
||||||
virtual IPAddress remoteIP();
|
|
||||||
virtual uint16_t remotePort();
|
|
||||||
|
|
||||||
friend class EthernetServer;
|
friend class EthernetServer;
|
||||||
|
|
||||||
|
@ -75,22 +75,15 @@ void loop() {
|
|||||||
for (byte i=0;i<4;i++) {
|
for (byte i=0;i<4;i++) {
|
||||||
if (!clients[i] && clients[i]!=client) {
|
if (!clients[i] && clients[i]!=client) {
|
||||||
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;
|
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) {
|
if (client.available() > 0) {
|
||||||
|
Reference in New Issue
Block a user