-
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
documentation: add description for connected() and status() #8329
base: master
Are you sure you want to change the base?
Conversation
ref. the original PR and the discussion esp8266#4626 esp8266#6701
And as #6701 already mentioned, this is somewhat different for the secure variant: Arduino/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp Lines 259 to 264 in 9d024d1
But, it's unclear whether this refers to the WiFiClient interface or the basic-socket WiFiClient class |
To summarize the need for this change: So indeed I think this PR should also remove the
The TLS context is supposed to match the WiFiClient class. |
...true, but also note that it is used internally. can update, but it may be better suited as a separate patch Will update with the 'connected' part with the reasoning, seems like a good place to also explain things |
Right! |
connected | ||
~~~~~~~~~ | ||
|
||
Unlike the reference implementation, ``connected()`` means that the client is available for both reads and writes. It will return ``true`` when the client is ``status() == ESTABLISHED`` or ``available() == true``, but will return ``false`` when the ``status() == CLOSED``. Please use ``status()`` for the connection information, ``availableForWrite()`` to check whether it is possible to write, and ``available()`` if you mean to check whether there's unread data. |
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.
It will return
true
when the client isstatus() == ESTABLISHED
oravailable() == true
, but will returnfalse
when thestatus() == CLOSED
.
According to current code, it will return false if the connection is closed, regardless available()
result,
meaning "writing is not allowed".
available()
can still be checked to tell if something has been received but kept unread.
Arduino/libraries/ESP8266WiFi/src/WiFiClient.cpp
Lines 329 to 335 in f401f08
uint8_t WiFiClient::connected() | |
{ | |
if (!_client || _client->state() == CLOSED) | |
return 0; | |
return _client->state() == ESTABLISHED || available(); | |
} |
ref. the original PR and the discussion
#4626
#6701
as mentioned in the #8327 (comment)
(I have yet to check the readthedocs rendering)