Changing TCP listening port not possible on the ESP32
Posted: Wed Oct 17, 2018 11:28 pm
Hello,
When using the Arduino IDE and the ESP8266 we declare a global WiFiServer before the setup() code like this:
and later in the setup code or in the loop code we can change the listening port like this:
This is useful when the port number for TCP communication is not previously defined or when it is defined by the user during a setup phase.
Unfortunately this does not work with the ESP32. If we do the same we got this error:
I wonder if there is a way to bypass this problem without fixing "à priori" the port number.
Regards, Luis
When using the Arduino IDE and the ESP8266 we declare a global WiFiServer before the setup() code like this:
Code: Select all
WiFiServer myServer(0); // to be changed later at run-time
Code: Select all
myServer.begin(myPort);
Unfortunately this does not work with the ESP32. If we do the same we got this error:
Code: Select all
no matching function for call to 'WiFiServer::begin(unsigned int&)'
Regards, Luis