Skip to content

Remote IP on EthernetClient #5234

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
DarioDaF opened this issue Aug 11, 2016 · 4 comments
Closed

Remote IP on EthernetClient #5234

DarioDaF opened this issue Aug 11, 2016 · 4 comments
Labels
feature request A request to make an enhancement (not a bug fix) Library: Ethernet The Ethernet Arduino library

Comments

@DarioDaF
Copy link

I sudgest adding a function to read the IP of the Clients

Changes needed:

EthernetClient.h

class EthernetClient : public Client {

public:

  virtual uint8_t remoteIP(uint8_t *buf); // Change

};

EthernetClient.cpp

uint8_t EthernetClient::remoteIP(uint8_t *buf) {
  if (_sock != MAX_SOCK_NUM)
    return W5100.readSnDIPR(_sock, buf);
  return 0;
}

It is a simple and usefull change in the library that can be used to retrive the IP address of a client connected to the EthernetServer.

@sandeepmistry sandeepmistry added the Library: Ethernet The Ethernet Arduino library label Aug 11, 2016
@PaulStoffregen
Copy link
Contributor

If this is added, it probably ought to use the IPAddress class from the core library rather than an array of bytes. Long-term, the C++ class can be much more easily extended to support IPv6.

@q2dg
Copy link

q2dg commented Aug 12, 2016

Well...maybe it's worthy read this: #1700

On the other hand, a week ago I suggested more some love to this and others improvements on Ethernet library...: arduino-libraries/Ethernet#36 (comment)

@per1234
Copy link
Collaborator

per1234 commented Aug 12, 2016

Well...maybe it's worthy read this: #1700

Yes, this was discussed in 2013 and rejected but maybe worth revisiting? Note that implementation uses IPAddress: ca37de4
I've been using that function for a couple years and I think it would be nice for consistency with EthernetUDP which already has remoteIP().

Here's the associated discussion on the Developers mailing list: https://groups.google.com/a/arduino.cc/forum/#!searchin/developers/remoteIP/developers/LW2xYj3LPM0/orkaW_SiNpAJ. The link to it on that PR has gone dead.

@per1234 per1234 added the feature request A request to make an enhancement (not a bug fix) label Jul 4, 2017
@per1234
Copy link
Collaborator

per1234 commented Jul 26, 2018

Fixed by arduino-libraries/Ethernet@ac84329

@per1234 per1234 closed this as completed Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request to make an enhancement (not a bug fix) Library: Ethernet The Ethernet Arduino library
Projects
None yet
Development

No branches or pull requests

6 participants
@PaulStoffregen @sandeepmistry @q2dg @per1234 @DarioDaF and others