added socket validation