Send a dummy event and see if you get an ACK in response. Depends on the library you're using.
You might want to look into timeouts or error callbacks on your connection library/framework.
All this is done at the kernel level, so at the application level you should be able to just verify if the connection is open by trying a read from the socket.
If anyone knows any library or framework in any language that solves this problem, I'd love to hear about it.