The documentation for QNEthernet::EthernetClient::close() notes that it closes the connection, but does so in a non-blocking fashion. Overall, I really like QNEthernet, because just about everything can be made non-blocking, which is something I find essential for the overall architecture of the project I'm working on.
So what I anticipate doing to close a connection is to call EthenetClient::close(), and then place the EthernetClient class instance in a collection of "clients with close pending". Then in my Tick() method, which is called on a regular basis, I'd want to check if the connection has been fully closed, i.e. FIN->ACK has gone both ways. Only then do I want to delete the EthernetClient, note that during the connect process it was created by a call to new EthernetClient;.
This raises the question of how do I detect that the client is fully disconnected during the Tick() method? Calling EthernetClient::connected() looks promising, but without explicit documentation, I can't be certain that it's not called early in the process, e.g. as soon as the local TCP stack has sent the first FIN packet. If I tear the client down at that point, the remote system will never see an ACK for its FIN, which is not at all desirable.
So what I anticipate doing to close a connection is to call EthenetClient::close(), and then place the EthernetClient class instance in a collection of "clients with close pending". Then in my Tick() method, which is called on a regular basis, I'd want to check if the connection has been fully closed, i.e. FIN->ACK has gone both ways. Only then do I want to delete the EthernetClient, note that during the connect process it was created by a call to new EthernetClient;.
This raises the question of how do I detect that the client is fully disconnected during the Tick() method? Calling EthernetClient::connected() looks promising, but without explicit documentation, I can't be certain that it's not called early in the process, e.g. as soon as the local TCP stack has sent the first FIN packet. If I tear the client down at that point, the remote system will never see an ACK for its FIN, which is not at all desirable.