Adding select.select to detect connection failures. Reference #913.