merge in socket check code from trendsetter