Ethernet Library- Server Mode-

Hello all,

I am developing a project to drive some arduino device (IOT spirit) using hosted webserver that will communicate with.
For a particular task I would like to determine (automatically) if the client is locally connected on the same LAN, witch would mean he is on location else he would be outside.

Is there any from the ARDUINO to get this information directly ?

Is there a way for the server to determine if the request come from same public IP than the ARDUINO to control and forward then a specific command ?

I have that capability with my server. It requires accessing lower level libraries. I can determine which IP (public or localnet) the request is coming from.

This code works with the ethernet library included with the IDE. If you use the Wiznet library, it requires a simple mod to the library to add the getSocketNumber function.

#include <Ethernet.h>
#include <utility/w5100.h>

byte thisSocket;
byte remoteIP[4];

    thisSocket = client.getSocketNumber();
    Serial.print(F("socket "));
    Serial.print(thisSocket);
    Serial.print(F(": "));

    W5100.readSnDIPR(thisSocket,remoteIP);

// here is where you would do a comparison to your localnet IP range
    Serial.print(remoteIP[0]);
    Serial.print(".");
    Serial.print(remoteIP[1]);
    Serial.print(".");
    Serial.print(remoteIP[2]);
    Serial.print(".");
    Serial.print(remoteIP[3]);