improve socket pointer checking