Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By JimDrew
#64454 Yes, I have tried all variations of this and nothing works.

There is no .setPort() function, and no way of specifying a new port according the SDK for Arduino. So, if you know of way, please let me know!

You can certainly make two listening ports, but you can't change either of the port addresses.
User avatar
By JimDrew
#64457 I read what you wrote. How do you add setPort() to the library, especially since the Arduino SDK lists no way for changing the port address?

Can you provide your code? Thanks!

I tried doing things like:

WiFiServer tempServer(newPort);
tcpServer.stop();
tcpServer = tempServer;
tempServer.stop();

This works perfectly for clients, but not for servers.
User avatar
By martinayotte
#64458 You need to edit the files directly, and stay aware that those changes will be overwritten during next update.

In file esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiServer.h :

Code: Select allvoid setPort(uint16_t port);


In file esp8266/2.3.0/libraries/ESP8266WiFi/src/WiFiServer.cpp :

Code: Select allvoid WiFiServer::setPort(uint16_t port)
{
    _port = port;
}