better socket management