Fixed default setting issue. Added try..catch... around socket code