Catch IOExceptions in Connection.cs. 

A probable fix for #4083 and #4423.