diff --git a/AUTHORS b/AUTHORS index 14097dff..80168838 100644 --- a/AUTHORS +++ b/AUTHORS @@ -29,6 +29,7 @@ Michael Margolis https://github.com/michaelmargolis Norbert Truchsess https://github.com/ntruchsess Paul Stoffregen https://github.com/PaulStoffregen per1234 https://github.com/per1234 +KMPElectronics https://github.com/kmpelectronics Richard Sim Scott Fitzgerald https://github.com/shfitz Thibaut Viard https://github.com/aethaniel diff --git a/src/Ethernet.h b/src/Ethernet.h index 376e6c59..7f8fcb0e 100644 --- a/src/Ethernet.h +++ b/src/Ethernet.h @@ -253,11 +253,16 @@ class EthernetClient : public Client { class EthernetServer : public Server { private: uint16_t _port; + void initSocket(); public: EthernetServer(uint16_t port) : _port(port) { } EthernetClient available(); EthernetClient accept(); +#ifdef ESP32 + virtual void begin(uint16_t port = 0); +#else virtual void begin(); +#endif virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); virtual operator bool(); diff --git a/src/EthernetServer.cpp b/src/EthernetServer.cpp index ddebd154..d9b7bf8b 100644 --- a/src/EthernetServer.cpp +++ b/src/EthernetServer.cpp @@ -24,8 +24,7 @@ uint16_t EthernetServer::server_port[MAX_SOCK_NUM]; - -void EthernetServer::begin() +void EthernetServer::initSocket() { uint8_t sockindex = Ethernet.socketBegin(SnMR::TCP, _port); if (sockindex < MAX_SOCK_NUM) { @@ -37,6 +36,22 @@ void EthernetServer::begin() } } +#ifdef ESP32 +void EthernetServer::begin(uint16_t port) +{ + if (port) { + _port = port; + } + + initSocket(); +} +#else +void EthernetServer::begin() +{ + initSocket(); +} +#endif + EthernetClient EthernetServer::available() { bool listening = false;