Comparing Print* sub-classes

Often, when I'm using an ethernet shield (W5100) for data acquisition, I like to allow more than 1 simultaneous incoming connection for remote debugging & configuration purposes. So I declare 4 EthernetClients to handle the 4 simultaneous connections that the W5100 supports. It's my understanding that the Serial & EthernetClient classes are both Stream sub-classes or something like that (not exactly sure what the lingo is).

Now at times, I like to know if the current data I'm processing is from Serial or one of the EthernetClients so in the past I've been using a function like this.

boolean comparePrintObj(Print *_item1, Print *_item2){
  if (_item1 == _item2){    // for some reason this comparison does not work anymore
    return true;
  }
  return false;
}

And call it like this where _dataSource is a Print* object.

for (byte i=0;i<4;i++){
  if (comparePrintObj(_dataSource, &client[i])){
    lastConnectionTime = millis();
  }
}

It used to work but now lately is only returns false. I expect an Arduino core/IDE update broke it but I'm not smart enough to figure out how/why.

Am I missing something obvious? (It's always obvious once you know)

why not if (_dataSource != (&Serial)) ?

That seems to work when comparing to Serial (it detects when it is or is not the Serial object) but not to my EthernetClients.

EthernetClient client[4];
for (byte i=0;i<4;i++){
  if (_dataSource == (&client[i])){
    Serial("\r\n   eth client match found: ");
    Serial(i);
    lastConnectionTime = millis();
  }
}

That never matches.

EthernetClient clnt = server.available();

And if it's a new clnt, then

client[i] = clnt;

try

if (client == &_dataSource)
this will use the == operator of EthernetClient which compares socket index

I tried

if ((&client[i]) == _dataSource)

and

if ((&client[i]) == &_dataSource)

Both compile but the comparison is always false.

m_elias:
I tried

if ((&client[i]) == _dataSource)

and

if ((&client[i]) == &_dataSource)

Both compile but the comparison is always false.

I recommended something else

Thanks for the suggestions. I'll probably just use an index to track it then.

m_elias:
I tried

if ((&client[i]) == _dataSource)

and

if ((&client[i]) == &_dataSource)

Both compile but the comparison is always false.

if (client == &_dataSource)
should work