ArduinoWiFiServer with send-to-all-clients functionality#7612
ArduinoWiFiServer with send-to-all-clients functionality#7612earlephilhower merged 7 commits intoesp8266:masterfrom JAndrassy:ArduinoWiFiServer
Conversation
|
I think this is pretty cool, @JAndrassy! I would be careful about how |
Thank you @earlephilhower . I am not sure if it is useful, but at least it shows the difference between Servers in Arduino libraries and in ESP libraries. I attempted to test the SSL server, but telnet-ssl could not connected. I will test it again if this PR should be merged. |
|
@earlephilhower, multiple copies of BearSSL::WiFiClientSecure for one connection are not in sync. so ArduinoWiFiServer doesn't work because the copy it holds still returns available() based on _recvapp_len, even if the copy returned before already read the data from the connection. if the data is read again esp8266 crashes. axTLS works (the copies share the context object) |
From what I understand, there's only one copy for each client, given by |
the concept of Arduino Client is that multiple copies of WiFiClient/EthernetClient (created as return values or parameters passed by copy) can interact with the same TCP connection. WiFiClient should be only a pointer to internal representation. In ESP8266WiFi library the WiFiClient does it with ClientContext. the axTLS does it very very nice with the std shared pointer to SSLContext. (I think this strange concept of Arduino API classes has origin in simulating Java objects behaviour for some sketch source compatibility with Processing framework. so no In the ArduinoWiFiServer template the array of 'monitored' WiFiClient objects has instance pointing to the connection and server.available() returns a copy always when data are available for it. So the WiFiClient object in the array |
Right, I think we agree, I was meaning: "From what I understand, there's only one TCP instance for each client, given by ::accept().". However maybe you should call on every occasion and even if it's useless |
for BearSSL the problem are the two copies of WiFiClientSecure for the same connection. one in the array of monitored clients and second in sketch filled at return from server.available(). the sketch reads data over its copy. the buffer counter _recvapp_len gets to 0. but the instance in the array still has the original value of _recvapp_len and returns the client again as if it has data available. available() calls bool() for every monitored client and bool() calls connected. |
That is true. I wasn't aware. |
|
Can you try with #7680 ? |
|
and second client gets for the second client "BSSL:_connectSSLServerRSA: OOM error" is logged |
|
Thanks to @earlephilhower 's suggestion in gitter patched example: |
and with available() working according to Arduino documentation plus PagerServer example
and with available() working according to Arduino documentation. plus PagerServer example.
should the ESP8266WiFi library have this?