# 区域访问限制 (/zh-CN/realtime-media/rtc-server-sdk/build/set-region/java) > For AI agents: see the complete documentation index at [llms.txt](/llms.txt). 为适应不同国家或地区的法律法规,声网支持限定访问区域功能。 开启限定访问区域功能后,不论用户在哪个区域使用你的 app,SDK 都只会访问指定区域的声网服务器。 例如你指定了北美为访问区域,假设有两位用户分别从北美和中国连接声网服务器: 指定访问区域 App 用户所在区域 SDK 实际访问区域 连接后的用户体验 北美 北美 北美 正常 中国 可能受到较大影响。由于指定区域与 app 用户所在区域之间存在跨区域公共互联网,公共互联网网络质量较差会导致音视频体验受到影响。如果指定区域的服务器都不可用,SDK 会直接报错。 :::info[信息] - 如果指定区域的服务器都不可用,SDK 会直接报错。 - 区域访问限制是 SDK 的高级设置功能,声网建议你仅在有访问安全限制的场景使用。 ::: ## 实现方法 [#实现方法] 服务端 SDK 支持限定区域访问。一旦指定了访问区域,音视频和消息数据将不会访问指定区域以外的服务器。 你需要在调用 `initialize` 方法初始化 `IAgoraService` 实例时,通过设置 `AgoraServiceConfiguration` 中的 `areaCode` 参数来指定访问区域。 - `0xFFFFFFFF`: (默认)全球。 - `0x00000001`: 中国大陆。 - `0x00000002`: 北美。 - `0x00000004`: 欧洲。 - `0x00000008`: 除中国大陆以外的亚洲区域。 - `0x00000010`: 日本。 - `0x00000020`: 印度。 区域码支持位操作。 ## 示例代码 [#示例代码-1] ```java // Creates an AgoraService object AgoraService service = new AgoraService(); if (null == service) { System.out.printf("createAndInitAgoraService fail\n"); return; } AgoraServiceConfig config = new AgoraServiceConfig(); // Disables the audio device module (Normally we do not directly connect audio capture or playback devices to a server) config.setEnableAudioDevice(0); // Enables the audio processing module config.setEnableAudioProcessor(1); // Whether to enable video config.setEnableVideo(0); // Specify North America as the region for connection config.setAreaCode(0x00000002); int ret = service.initialize(config); ```