socket state management