class PG::Connection

def check_socket

To verify that the communication to the server works, it is recommended to use something like conn.exec('') instead.
The method doesn't verify that the server is still responding.

Raises a kind of PG::Error if there was an error reading the data or if the socket is in a failure state.

Only pending data is read from the socket - the method doesn't wait for any outstanding server answers.
No communication is done with the server.
This verifies that the connection socket is in a usable state and not aborted in any way.

Read all pending socket input to internal memory and raise an exception in case of errors.
def check_socket
	while socket_io.wait_readable(0)
		consume_input
	end
	nil
end