tiberius icon indicating copy to clipboard operation
tiberius copied to clipboard

Check if client TCP connection is not closed

Open dtheodor opened this issue 3 years ago • 4 comments

This is more of a question than an issue. Is there a way to check if the TCP connection is not closed? As far as I can tell the TcpStream is not exposed in any way from the client and thus its methods are not usable

dtheodor avatar Mar 31 '22 17:03 dtheodor

Yep. We accept everything that is AsyncRead + AsyncWrite, including things such as the NamedPipeClient. This means having a specific API for asking the questions from whatever implements these traits is not the easiest thing to do.

Do you need to get that info from the connection, or would a dumbest and fastest possible query do the trick?

pimeys avatar Mar 31 '22 17:03 pimeys

Thanks for the response. I wanted a cheap way to check for the connection status without having to send anything over the wire (which is not 100% reliable but good enough). Would it be possible to expose the concrete underlying transport from a client method?

dtheodor avatar Mar 31 '22 18:03 dtheodor

In particular I wanted to use something like this http://stefan.buettcher.org/cs/conn_closed.html to detect closed connections. I am exploring options, without being certain that this is doable with tokio.

dtheodor avatar Mar 31 '22 18:03 dtheodor

If you'd like to try up with a PR to see what kind of API would work for you, I'd give it a review and merge to main if it works.

pimeys avatar Mar 31 '22 18:03 pimeys