See test case below (not compile tested).
Thx.
WiFiServer server(9001);
boolean testchange = true;
void setup (void)
{
server.begin()
}
void loop (void) {
if (testchange == true)
{
# Does this work, is it OK to do?
server = WiFiServer(8001);
# Do we need to call begin again?
sever.begin()
testchange = false;
}
....
## Do stuff with server here.
....
}