Changing TCP listening port not possible on the ESP32

Vladis
Posts: 4
Joined: Thu Mar 22, 2018 6:00 am

Changing TCP listening port not possible on the ESP32

Postby Vladis » 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:

Code: Select all

WiFiServer myServer(0);  // to be changed later at run-time
and later in the setup code or in the loop code we can change the listening port like this:

Code: Select all

myServer.begin(myPort);
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:

Code: Select all

no matching function for call to 'WiFiServer::begin(unsigned int&)'
I wonder if there is a way to bypass this problem without fixing "à priori" the port number.

Regards, Luis

bobtidey
Posts: 43
Joined: Mon Jun 18, 2018 2:24 pm

Re: Changing TCP listening port not possible on the ESP32

Postby bobtidey » Thu Oct 18, 2018 11:24 am

begin does not take a parameter.

I think you can just repeat the instance using myServer(myPort); before doing the begin.

Vladis
Posts: 4
Joined: Thu Mar 22, 2018 6:00 am

Re: Changing TCP listening port not possible on the ESP32

Postby Vladis » Fri Oct 19, 2018 10:06 am

Hello again,

I am sorry for my post. Actually it is possible to change the TCP port at run time as we do with the ESP8266. I was not using the 1.0.0 ESP32 core for Arduino. Once installed the begin method accepts a parameter and there is no error.

Regards Luis

bobtidey
Posts: 43
Joined: Mon Jun 18, 2018 2:24 pm

Re: Changing TCP listening port not possible on the ESP32

Postby bobtidey » Fri Oct 19, 2018 10:20 am

I see now the port argument has been added into to later versions than I had.

That's good. Time to update.

Who is online

Users browsing this forum: No registered users and 99 guests