socket logic