Skip to content

WiFiServer::write() write to all clients is not implemented #2743

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

Closed
MeFisto94 opened this issue Dec 7, 2016 · 2 comments · Fixed by #6338
Closed

WiFiServer::write() write to all clients is not implemented #2743

MeFisto94 opened this issue Dec 7, 2016 · 2 comments · Fixed by #6338
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Comments

@MeFisto94
Copy link

Basic Infos

So I tried searching if this issue is already present but due to the mass it could be that I overlooked it, so apologies if this is a duplicate report.

Description

The WiFiServer currently doesn't support writing to all clients. Instead one has to keep track of the client instances and do that manually which leads to a bit more ugly code.

See: WiFiServer.cpp#L135

I would file a pull request but since I am no C++ expert, the list code is hard to read.
In general I would recommend refactoring the code to be in line with the Arduino's EthernetServer.

The key difference is that it handles the client array internally, hiding it from the user.
This means that available always returns the first readable client instead of only returning new connections like WiFiServer does.

I agree that this is a design decision and that it would break exisiting code, so this is soley a proposal, but since I had to rewrite some code depending on the Platform (Arduino Mega vs ESP it would be awesome to have that consistent.

@devyte
Copy link
Collaborator

devyte commented Oct 6, 2017

@igrr is this something that we want to do for compatibility or consistency?

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 6, 2017
@igrr
Copy link
Member

igrr commented Oct 6, 2017

I don't see a problem with adding a function to write to all clients. It wasn't implemented in the first place because that looked like an odd thing to do (no widely used protocol over TCP does that, AFAIK). Still, implementing this would not hurt and would improve compatibility.

The other part, about available returning WiFiClient which has data available for reading, rather than the first newly connected WiFiClient, would indeed break existing code, for example in the case when a remote client connects to WiFiServer and doesn't send any data (expecting the Server to send something). So for this part, we probably don't want to change the implementation.

earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Jul 24, 2019
Fixes esp8266#5116
Fixes esp8266#2743

The Arduino WiFiClient object allows sending the same packet to all
connected clients of a WiFiServer.  In their implementation it may make
sense, but on the 8266 with things like SSL it doesn't.

Update the docs to note that WiFiServer::write() is a no-op, and that
the app should use the WiFiCliebnt::write() on all connected clients as
appropriate.
d-a-v pushed a commit that referenced this issue Jul 25, 2019
Fixes #5116
Fixes #2743

The Arduino WiFiClient object allows sending the same packet to all
connected clients of a WiFiServer.  In their implementation it may make
sense, but on the 8266 with things like SSL it doesn't.

Update the docs to note that WiFiServer::write() is a no-op, and that
the app should use the WiFiCliebnt::write() on all connected clients as
appropriate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants