-->
Page 1 of 1

Is it possible to have two ports open simultaneously?

PostPosted: Thu Feb 11, 2016 6:26 am
by llrjt100
I'm trying to work out how to simultaneously have a web server listening on port 80 so I can display a status page, and a tcp server listening on port 9999 so I can respond to serial commands. The web server page string and command string processing needs to be done on the Arduino with the ESP8266 handling all the tcp and connection stuff.

If it's not possible to have two ports open at once, I'm wondering if I can use a single port, and somehow distinguish between http GETs or command string responses and direct to the appropriate web server or serial string processing in my code (although I guess this requires two clients connected to the same port at once which isn't possible?)

My knowledge of this stuff is limited, so any thoughts would be much appreciated! I'm trying to use and ESP8266 to replace an Ethernet Shield which allows me to do the following:

EthernetServer cmdserver(9999);
EthernetClient cmdclient;

EthernetServer webserver(80);
EthernetClient webclient;

Many thanks,
Richard

Re: Is it possible to have two ports open simultaneously?

PostPosted: Thu Feb 11, 2016 9:07 am
by martinayotte
I'm using 2 ports without any problem.

Code: Select allESP8266WebServer webserver(80);
WiFiServer tcpserver(23); // Telnet Port

Then, you need to handle both in the loop()