Moderator: igrr
You would have to add a new setPort() method, and then using code like this one :
tcpserver.close();
tcpserver.setPort(newport);
tcpserver.begin();
EDIT : If you don't wish to add new setPort() method, it can still be accomplish by using two instances of WiFiServer, one with old port and the other with new port and do the switch like :
tcpserver1.close();
tcpserver2.begin();
Thus doesn't prevent the code provided to be able to compile.
Did you tried it out ?