atesin
November 17, 2024, 9:10pm
1
hi... does anybody knows how to do this? .. example:
one instance listening port 80 as webserver
another one listening port 23 as telnet (or netcat), for webserver admin + debug
another question: does anybody knows how to config and start these servers at RUNTIME?... example:
i connect to port 23 telnet console
i decide AT RUNTIME if i start the other server as webserver (port 80) or ftp (port 21), or any other at random port
(protocol doesnt matter, just wanna know if can i start a random port server at runtime)
yikes... that was 2 questions! xD
Juraj
November 19, 2024, 8:05am
4
which library?
some have server.begin(port) and server..end() some have not
atesin
November 19, 2024, 5:12pm
5
Juraj
November 19, 2024, 6:33pm
6
esp8266 WiFiServer has end() and begin(port) so you can have a global WiFiServer and stop it with end() any time and start it at any port at any time with begin(port)
atesin
November 19, 2024, 9:04pm
7
begin(port) ??? ... really??
so unlike wifi arduino library, esp8266 server can be started, with port being choosen at runtime??
esp server begin() is not documented, it just say "functions similar to arduino server class" and gives a link to there, arduino server.begin() accepts no parameters
atesin
November 21, 2024, 4:54pm
9
omg that is new... is not "documented" (as i said, docs just links to arduino wifi lib, which doesnt have this feature)
so in theory can i do something like this?... what a shame is not documented and nobody knows :
#include <ESP8266WiFi.h>
WiFiServer telnetSrv(23);
WiFiServer myServer();
void parseTelnetCmd(char* cmd){
if ( !strcmp(cmd, "startserver"){
// ...
startServer(port)
}
}
void startServer(int port){
myServer.begin(port);
}
void loop(){
if ( telnetSrv.available() ){
// ...
parseTelnetCmd(cmd)
}
doSomethingWith(myServer);
}