1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

WiFiServer - 'rename' available() to accept() (#8419)

* WiFiServer - 'rename' available() to accept()
* use server.accept() instead of available()
* WiFiServer.accept() and ArduinoWiFiServer class doc update
This commit is contained in:
Juraj Andrássy
2022-01-03 14:32:02 +01:00
committed by GitHub
parent 2f58f679ee
commit f401f08aba
20 changed files with 53 additions and 27 deletions

View File

@ -12,13 +12,29 @@ Methods documented for the `Server Class <https://www.arduino.cc/en/Reference/Wi
5. `print() <https://www.arduino.cc/en/Reference/WiFiServerPrint>`__
6. `println() <https://www.arduino.cc/en/Reference/WiFiServerPrintln>`__
In ESP8266WiFi library the ``ArduinoWiFiServer`` class implements ``available`` and the write-to-all-clients functionality as described in the Arduino WiFi library reference. The PageServer example shows how ``available`` and the write-to-all-clients works.
For most use cases the basic WiFiServer class of the ESP8266WiFi library is suitable.
Methods and properties described further down are specific to ESP8266. They are not covered in `Arduino WiFi library <https://www.arduino.cc/en/Reference/WiFi>`__ documentation. Before they are fully documented please refer to information below.
accept
~~~~~~
Method ``accept()`` returns a waiting client connection. `accept() is documented <https://www.arduino.cc/en/Reference/EthernetServerAccept>`__ for the Arduino Ethernet library.
available
~~~~~~~~~
.. deprecated:: 3.1.0
see ``accept``
``available`` in the ESP8266WiFi library's WiFiServer class doesn't work as documented for the Arduino WiFi library. It works the same way as ``accept``.
write (write to all clients) not supported
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please note that the ``write`` method on the ``WiFiServer`` object is not implemented and returns failure always. Use the returned
``WiFiClient`` object from the ``WiFiServer::available()`` method to communicate with individual clients. If you need to send
``WiFiClient`` object from the ``WiFiServer::accept()`` method to communicate with individual clients. If you need to send
the exact same packets to a series of clients, your application must maintain a list of connected clients and iterate over them manually.
setNoDelay

View File

@ -92,7 +92,7 @@ Serving of this web page will be done in the ``loop()`` where server is waiting
void loop()
{
WiFiClient client = server.available();
WiFiClient client = server.accept();
if (client)
{
// we have a new client sending some request
@ -196,7 +196,7 @@ Complete sketch is presented below.
void loop()
{
WiFiClient client = server.available();
WiFiClient client = server.accept();
// wait for a client (web browser) to connect
if (client)
{