Fix reference to socket.error.
Rename the method that we copied from socket and only use it when creating ssl connections.