-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WiFiSever - Arduino API available() and accept() #7605
Conversation
It seems to be a fair request, in the name of compatibility with Arduino API. However, it would break many sketches and libraries because of the significant There will be no change for simple TCP server answering to a simple request then closing. We can't really fully deprecate What could be done:
pros:
cons:
This proposal raises several potential issues depending on how these defines are really defined by the user/sketch/library. |
In the years esp8266 Arduino exists, missed someone the true Arduino behaviour of available()? I think not. |
now I realized that the Arduino implementation of
maybe a WiFiArduinoServer could inherit from WiFiServer and add the Arduino style available() function and the write-to-all-clients functionality. (same for SSL server) |
That would be a very good first step. |
I rework this PR. Should I use WiFiClient or ClientContext to store the clients? (ClientContext with ref and unref) |
I think you have noticed that |
this will be the example called PagerServer, a simple server that echoes any incoming messages to all connected telnet clients.
I think it is Arduino way elegant. https://github.com/jandrassy/WiFiEspAT/blob/master/examples/Basic/PagerServer/PagerServer.ino |
next attempt #7612 |
According to documentation, the
server.available()
should return first client with data available.https://www.arduino.cc/en/Reference/WiFiServerAvailable (esp8266 doc points there).
ESP8266WiFi library now does what a new EthernetServer.accept() method does: https://www.arduino.cc/en/Reference/EthernetServerAccept. It was added to Ethernet library by Paul Stoffregen in 2018 for Ethernet 2.0. I added it to UIPEthernet in February and I have it in my WiFiEspAT library too.
This PR shows a draft of a possible implementation of
available()
. (This quick implementation could let some client wait to long.)My opinion is that it is strange to have a function like this available(). My explanation how they defined it like this, is that the networking libraries by Arduino are always remote APIs for a firmware and there it doesn't look so strange.