changed socket handling.