Hi.
Any way to define server port inside setup() with standard ethernet lib and ethernet shield w5100 and basic server code: webserver?
I need this because I'm using a sd-card to store all ethernet values ( IP, MAC,DNS, etc.. ) and read the value from the sd-card at setup, this is working nicely (zoomkat code), but so far no success for server_port. I got "server not defined in this scope" in loop() if I declare port number inside setup();
Something like this.
void setup() {
...
EthernetServer server(server_port);
...
}
But so far no success. I got all time "server not defined in this scope".
Thanks.
Declare server in global area, then assign port inn setup.
EthernetServer server;
Void setup)) {
server = EthernetServer(server_port);
That should work. I'm not at my computer to test it.
SurferTim:
Declare server in global area, then assign port inn setup.
EthernetServer server;
Void setup)) {
server = EthernetServer(server_port);
That should work. I'm not at my computer to test it.
Thanks.
But with no success.
Similar error log that I got with my previous tests.
WebServer:31: error: no matching function for call to 'EthernetServer::EthernetServer()'
WebServer.ino:31:16: note: candidates are:
In file included from C:\Program Files\Arduino\libraries\Ethernet\src/Ethernet.h:8:0,
from WebServer.ino:19:
C:\Program Files\Arduino\libraries\Ethernet\src/EthernetServer.h:14:3: note: EthernetServer::EthernetServer(uint16_t)
EthernetServer(uint16_t);
^
C:\Program Files\Arduino\libraries\Ethernet\src/EthernetServer.h:14:3: note: candidate expects 1 argument, 0 provided
C:\Program Files\Arduino\libraries\Ethernet\src/EthernetServer.h:8:7: note: EthernetServer::EthernetServer(const EthernetServer&)
class EthernetServer :
^
C:\Program Files\Arduino\libraries\Ethernet\src/EthernetServer.h:8:7: note: candidate expects 1 argument, 0 provided
no matching function for call to 'EthernetServer::EthernetServer()'
I will keep trying.
Again, thanks for for tips.
I tested this and it works. I used port 23 as the default, and changed it in setup to 80.
EthernetServer server(23);
Void setup)) {
server = EthernetServer(server_port);
SurferTim:
I tested this and it works. I used port 23 as the default, and changed it in setup to 80.
EthernetServer server(23);
Void setup)) {
server = EthernetServer(server_port);
Hi.
Thanks.
That is.
It's working as needed.
One of my try was define server port in global area 1st, and after recall it with a variable in setup() but without success, your 2 tips was perfect for me.
Again thanks.