Moves socket handling to object