before reading from the server socket check whether its connected at all.