Skip to content
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

Enhancement: add operator==, localPort, remoteIP and remotePort to EthernetClient #1700

Merged
merged 7 commits into from Dec 9, 2013

Conversation

ntruchsess
Copy link
Contributor

EthernetServer doesn't provide any way to distinguish clients returned by Server.available() which makes it impossible to implement a Server that handles multiple persistent connections.

I added an operator == to allow this. It checks whether both Clients are assigned with the same socket-register by comparing _sock.

This will not recognize a change in the connection the socket-register handles. So in case the sketch stores a EthernetClient-reference and this clients connection is closed and reconnected by the W5100 you cannot detect this in your sketch by relying on the ==-operator.

To allow detection of this 'client became reconnected'-issue I've added methods localPort, remotePort and remoteIP. I have not includet localPort,remotePort and remoteIP in ==-operator to avoid unnessesary increase in memory-foodprint of the Client-object.

The updated AdvancedChatServer-example demonstrates the use of the ==-operator by distributing incomming messages to all clients but the one the message comes from. (The former ChatServer echos the messages back to the sending client).

@ntruchsess
Copy link
Contributor Author

as suggested on the developers-list http://thread.gmane.org/gmane.comp.hardware.arduino.devel/2689 I removed local/remotePort and remoteIP as they break other implementations of Client.
Having an operator== is the important part of this pull-request, the other methods may be addet at a later time when there's agreement about on the list.

cmaglie added a commit that referenced this pull request Dec 9, 2013
Enhancement: add operator==, localPort, remoteIP and remotePort to EthernetClient
@cmaglie cmaglie merged commit ffb8a55 into arduino:master Dec 9, 2013
ntruchsess added a commit to ntruchsess/arduino_uip that referenced this pull request Dec 9, 2013
@ntruchsess ntruchsess deleted the ethernetclient2 branch January 9, 2014 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants