EthernetServer::available() only returns a valid EthernetClient if the connection is established AND there is data available to read. I need a possibility to get the connected client also when there's nothing to read. (I want to listen on a tcp port and then transmit sensor data while the connection is established.)
I recommend a connected function in the EthernetServer class:
EthernetClient EthernetServer::connected()
{
accept();
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
EthernetClient client(sock);
if (EthernetClass::_server_port[sock] == _port &&
(client.status() == SnSR::ESTABLISHED ||
(client.status() == SnSR::CLOSE_WAIT && client.available()))) {
return client;
}
}
return EthernetClient(MAX_SOCK_NUM);
}
regards: Tom