From ed658f0d2564d43cb7290ca1ef3850015c2390ec Mon Sep 17 00:00:00 2001 From: 5a2v0 Date: Wed, 22 Jun 2016 16:20:32 +0200 Subject: [PATCH 1/6] Update EthernetServer.h I edited the line: EthernetServer(uint16_t); in EthernetServer(); and I added; virtual void begin(uint16_t); So user can choose in his sketch to use "server.begin();" without parameters and the library will use tcp port 80 as default, or user can use "server.begin(int);" and the webserver will start using the tcp port indicated in the sketch (for example the tcp port can be stored in eprom. At board's startup, it can read the value and use it, while before user must declare a fixed tcp port). --- libraries/Ethernet/src/EthernetServer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Ethernet/src/EthernetServer.h b/libraries/Ethernet/src/EthernetServer.h index 86ccafe9690..d63d1356d82 100644 --- a/libraries/Ethernet/src/EthernetServer.h +++ b/libraries/Ethernet/src/EthernetServer.h @@ -11,8 +11,9 @@ public Server { uint16_t _port; void accept(); public: - EthernetServer(uint16_t); + EthernetServer(); EthernetClient available(); + virtual void begin(uint16_t); virtual void begin(); virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); From 512abdd1c40bb406e98c5f2864bdfe5b8482d2bf Mon Sep 17 00:00:00 2001 From: 5a2v0 Date: Wed, 22 Jun 2016 16:41:46 +0200 Subject: [PATCH 2/6] Update EthernetServer.cpp I removed from the line: EthernetServer::EthernetServer() {} the "uint16_t port" declaration and then the "_port = port;" that I wrote into the modified begin constructor: So ".begin();" become ".begin(int);". If user don't declare nothing and use the previous method, library will use standard tpc port 80 with: void EthernetServer::begin() {begin(80); } Many thanks to Arduino's forum user: SukkoPera --- libraries/Ethernet/src/EthernetServer.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/Ethernet/src/EthernetServer.cpp b/libraries/Ethernet/src/EthernetServer.cpp index cfa813eb7be..87e9a464ae0 100644 --- a/libraries/Ethernet/src/EthernetServer.cpp +++ b/libraries/Ethernet/src/EthernetServer.cpp @@ -8,13 +8,11 @@ extern "C" { #include "EthernetClient.h" #include "EthernetServer.h" -EthernetServer::EthernetServer(uint16_t port) -{ - _port = port; -} +EthernetServer::EthernetServer() {} -void EthernetServer::begin() +void EthernetServer::begin(uint16_t port) { + _port = port; for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { EthernetClient client(sock); if (client.status() == SnSR::CLOSED) { @@ -26,6 +24,10 @@ void EthernetServer::begin() } } +void EthernetServer::begin() { + begin(80); +} + void EthernetServer::accept() { int listening = 0; From 7a97fd002d614d217dde408e8f637129eb0f80bd Mon Sep 17 00:00:00 2001 From: 5a2v0 Date: Wed, 22 Jun 2016 17:32:23 +0200 Subject: [PATCH 3/6] Update EthernetServer.cpp --- libraries/Ethernet/src/EthernetServer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/Ethernet/src/EthernetServer.cpp b/libraries/Ethernet/src/EthernetServer.cpp index 87e9a464ae0..13416fde562 100644 --- a/libraries/Ethernet/src/EthernetServer.cpp +++ b/libraries/Ethernet/src/EthernetServer.cpp @@ -24,9 +24,7 @@ void EthernetServer::begin(uint16_t port) } } -void EthernetServer::begin() { - begin(80); -} +void EthernetServer::begin() {} void EthernetServer::accept() { From 2233050f94e10fef8aec2a88e2ecaaca19ffa888 Mon Sep 17 00:00:00 2001 From: 5a2v0 Date: Wed, 22 Jun 2016 18:29:57 +0200 Subject: [PATCH 4/6] Update EthernetServer.cpp --- libraries/Ethernet/src/EthernetServer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/Ethernet/src/EthernetServer.cpp b/libraries/Ethernet/src/EthernetServer.cpp index 13416fde562..edcf074e1e4 100644 --- a/libraries/Ethernet/src/EthernetServer.cpp +++ b/libraries/Ethernet/src/EthernetServer.cpp @@ -24,7 +24,9 @@ void EthernetServer::begin(uint16_t port) } } -void EthernetServer::begin() {} +void EthernetServer::begin() { + begin(_port); +} void EthernetServer::accept() { From 0b6c62279d878bb182136dcccb1205363eaf7174 Mon Sep 17 00:00:00 2001 From: 5a2v0 Date: Wed, 22 Jun 2016 22:06:56 +0200 Subject: [PATCH 5/6] Update EthernetServer.cpp --- libraries/Ethernet/src/EthernetServer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/Ethernet/src/EthernetServer.cpp b/libraries/Ethernet/src/EthernetServer.cpp index edcf074e1e4..b25fcbe362e 100644 --- a/libraries/Ethernet/src/EthernetServer.cpp +++ b/libraries/Ethernet/src/EthernetServer.cpp @@ -8,6 +8,11 @@ extern "C" { #include "EthernetClient.h" #include "EthernetServer.h" +EthernetServer::EthernetServer(uint16_t port) +{ + _port = port; +} + EthernetServer::EthernetServer() {} void EthernetServer::begin(uint16_t port) From bb3d86a71ed625aa31524f212c9d7345d36e785f Mon Sep 17 00:00:00 2001 From: 5a2v0 Date: Thu, 23 Jun 2016 09:00:12 +0200 Subject: [PATCH 6/6] Update EthernetServer.h --- libraries/Ethernet/src/EthernetServer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/Ethernet/src/EthernetServer.h b/libraries/Ethernet/src/EthernetServer.h index d63d1356d82..83f14f8824a 100644 --- a/libraries/Ethernet/src/EthernetServer.h +++ b/libraries/Ethernet/src/EthernetServer.h @@ -11,6 +11,7 @@ public Server { uint16_t _port; void accept(); public: + EthernetServer(uint16_t); EthernetServer(); EthernetClient available(); virtual void begin(uint16_t);