Store if an error has occurred and return -1 with ENOTCONN from all future calls, avoiding attempts to use a broken connection.