Adding socket validation checks before operating on them. Added check to AFC response parsing.