Pages: [1]   Go Down
Author Topic: EthernetServer connected()  (Read 832 times)
0 Members and 1 Guest are viewing this topic.
Hungary
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
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
Logged

Pages: [1]   Go Up
Jump to: