It may be helpful to some if the ethernet library included a way to retrieve the client ip when using the server code. It can be used as a primitive firewall, preventing unauthorized client access. My library code changes to do this are already working.
http://arduino.cc/forum/index.php/topic,135082.0.html
The modified ethernet library code is attached to reply #1. It uses the new ip address format (IPAddress) in the same manner as the other ip functions in Ethernet.cpp.
IPAddress clientIP = client.remoteIP();
edit: This is the total code added. Nothing else changed.
Code added to EthernetClient module:
// EthernetClient.h
IPAddress remoteIP();
// EthernetClient.cpp
IPAddress EthernetClient::remoteIP() {
return Ethernet.remoteIP(_sock);
}
Code added to Ethernet module:
// Ethernet.h
IPAddress remoteIP(uint8_t s);
// Ethernet.cpp
IPAddress EthernetClass::remoteIP(uint8_t s) {
IPAddress ret;
W5100.readSnDIPR(s,ret.raw_address());
return ret;
}