How to know if TCPClient has sent the message

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' ...
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.

@rvnash Hi did you ever solve this one? I have a similar issue, but I am sending to an ftp server so I would normally expect some code back

How about using
Your server should send a reply

@pNrie unfortunately I have never been able to resolve the issue. I’m stuck with just delaying for some seconds
@ScruffR It isn’t my server, it is a service I’d like to use, and it does not send a reply, unfortunately. What I was hoping for was a flush() call that would wait until the output buffer was all sent. It doesn’t look like TCPClient.flush does that.

@rvnash, the existing flush() function does nothing and returns. You could do a timed client.available() loop and exit if the server doesn’t reply within a certain amount of time instead of the delay(5000). Unless there is a call deep within the WICED stack, either delay method are the only way to be sure the data went out.