You could even check $sockerr to determine why you couldn't connect, that way you wouldn't even be dependant on google being up.