refactor XSocket