Updated socket logic.