Matthew Hagerty <mhagerty(at)voyager(dot)net> writes:
> Anyone know a good *fast* way to test
> if a socket is still valid?
What exactly are you trying to defend against?
In general, I don't believe that there is any way of discovering whether
the server is still up, other than to send it a query. (FWIW, an empty
query string bounces back very quickly, with little processing.)
For particular scenarios it's possible that some notification has been
delivered to the client, but if you have had (say) a loss of network
connectivity then there just is no other alternative. Your end isn't
going to discover the connectivity loss until it tries to send a
message.
regards, tom lane