client: test socket connection before using it