I am writing a client that uses TCPClient to send a message to a service. The problem is that the service does not respond at all to the message, and I can’t change that. I want to close the client after the send, but I don’t know how long to wait, and I can’t wait for a response, because there isn’t one. Is there any way to know that the message has been sent?
TCPClient client; client.connect(server, port); ... more code to create the message 's' ... client.print(s); delay(5000); // Wait a little bit client.stop(); // Close the connection to server.
If I take out the delay and call stop immediately after the print, the message doesn’t get through. But I don’t know if the delay should be 50 milliseconds or 50 seconds. Is there anything I can poll for message completion? Does TCPClient.flush wait for completion?
Thanks for any help.