-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
SocketWrapper - MbedServer modernization (without available() and Print) #793
Conversation
MbedServer didn't manage clients for proper available() and print-to-all-clients. Now available() in derived server classes is deprecated and accept() is added with the same implementation. Inheriting from Print (Server) is removed. write methods for Print implementation are removed. They never worked. New are constructor without parameters, begin with parameter port and operator bool.
e15a0be
to
18b696b
Compare
now this is my last essential PR for Mbed Core networking. It does changes proposed by Alessandro Ranellucci, but including the consequences #750 adds accept() in WiFiServer consequences:
#751 adds end() in WiFiServer consequences:
other related server classes modernization as in WiFiS3:
Some context: The server.available() originates in Processing. It is an idea to simplify a TCP server for artists. But as the lack of proper server.available() here and in multiple third party libraries shows, users not expect that behavior. In most request-response-stop use-cases it doesn't even matter. Class Server inherits from Print for the print-to-all-clients functionality. This functionality is tied with the available() method implementation. The implementation of the Server class should register all connected clients for correct implementation of available() and for print-to-all-clients functionality. The base class Server can't declare required server methods available() and accept(), because they have the return type of the specific Client implementation of the library (for example EthernetClient in the Ethernet library). As a consequence, It is not possible to use the base class Server to work with an instance of an inherited server class. So Server is just disguised Print and without Print usage inheriting from Server class is useless. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JAndrassy is this still true? the whole system works but i cannot see the clients input in the serial monitor.
it is just a comment which is not true. it is same in the Ethernet library from where the example originates. |
MbedServer didn't manage clients for proper available() and print-to-all-clients. Now available() in derived server classes WiFiClient and EthernetClient is deprecated and accept() is added with the same implementation. Inheriting from Print (Server) is removed.
write
methods for Print implementation are removed. They never worked.New are constructor without parameters, begin with parameter port and end() as in the new WiFiS3 library.
The ChatServer examples never worked because they relay on Processing style server.available() and print-to-all-clients.. Removed.
ESP32 core and RP2040 core libraries too don't implement Processing style Servers. Processing style WiFiServer and EthernetServer for these cores and Mbed core is implemented in my NetAPIHelpers library. In my networking libraries WiFiEspAT and EthenetENC the print-to-all-clients is in separate class and in next major version I plan to remove server.available() and point to NetAPIHelpers Server.
This replaces PR #750 and #751
overview of Server implementations in libraries https://github.com/JAndrassy/Arduino-Networking-API/blob/main/ArduinoNetAPILibs.md#server-class