fixed socket handling