some fixes in socket condition detection