> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft 游戏开发工具包网络简介

> GDK 网络 API 概览，涵盖 HTTP、WebSocket、套接字、聊天与游戏数据，以及网络初始化与挂起和恢复的相关要求。

本文介绍 Microsoft 游戏开发工具包 (GDK) 中的网络堆栈。Microsoft 游戏开发工具包 (GDK) 游戏可用的网络堆栈和 API 与 Win32 网络 API 类似，简化了从现有 Win32 游戏的移植过程，并支持更加统一的网络实现。

## 可用 API

下表汇总了 Microsoft 游戏开发工具包 (GDK) 的 API 面。有关每个 GDK API 的更多信息，请参阅其对应链接。

| 功能                    |                                                                                                              Microsoft 游戏开发工具包 (GDK)                                                                                                             |
| --------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| 一站式解决方案（网络游戏数据和游戏内聊天） |                                                                           [PlayFab Party](/build/console-features/networking/game-mesh/playfab-party-intro-networking)                                                                           |
| 安全的客户端/服务器网络游戏数据传输    |                                                                                  [MsQuic](/build/console-features/networking/game-mesh/msquic-intro-networking)                                                                                  |
| REST                  |                                                                                     [XSAPI](https://developer.microsoft.com/games/xbox/docs/gdk/atoc-xsapi-c)                                                                                    |
| HTTP\*\*              |                                                  [xCurl](/build/console-features/networking/web-requests/intro-xcurl) 或 [WinHTTP](/build/console-features/networking/web-requests/intro-winhttp)                                                 |
| WebSocket\*\*         |                                   [libHttpClient](/build/console-features/networking/web-requests/http-networking#libhttpclient)（推荐）或 [WinHTTP](/build/console-features/networking/web-requests/intro-winhttp)                                   |
| 套接字                   |                                                                                 [Winsock](/build/console-features/networking/game-mesh/winsock-intro-networking)                                                                                 |
| 套接字安全                 | OpenSSL DTLS (Datagram Transport Layer Security) 或 Bcrypt DTLS [(安全游戏通信) (NDA 文章)](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/game-principles/security/communication-security/communication-security-impl/gc-secure-communication-impl) |
| 网络连接性                 |                                                                    [XNetworkingGetConnectivityHint](/build/console-features/networking/initialization-connectivity-networking)                                                                   |
| 端口行为                  |                                                                         [与 Win32 Windows PC 完全一致](/build/console-features/networking/game-mesh/winsock-intro-networking)                                                                         |
| 游戏内聊天                 |                                [PlayFab Party](/build/console-features/networking/game-mesh/playfab-party-intro-networking) 或 [Game Chat 2](/services/xbox-services/multiplayer/chat/game-chat2/game-chat-2-intro)                               |

\*\*：要了解如何选择使用哪种 API，请参阅 [Web 请求](/build/console-features/networking/web-requests/http-networking)。

## 新的重要概念

有两个新概念几乎适用于 Microsoft 游戏开发工具包 (GDK) 的每一个网络 API。

### 网络初始化

所有网络 API 只有在网络完成初始化后才能正常工作。游戏在调用任何网络 API 或任何依赖网络 API 的中间件之前，应先等待网络初始化。有关网络初始化的更多信息，请参阅 [网络初始化与连接性](/build/console-features/networking/initialization-connectivity-networking)。

### 挂起与恢复

几乎所有由网络 API 创建的网络句柄和对象都需要在游戏收到挂起通知时清理。每个 API 的概述文档都描述了针对该 API 的具体做法；游戏本身及使用这些 API 的任何中间件都应遵循这些指导。有关挂起与恢复的一般信息，请参阅 [XBOX 游戏生命周期 (NDA 文章)](/build/console-features/console-workflows/xbox-game-life-cycle#responding-to-suspend-and-resume) 概述。

挂起与恢复处理文档：

* [PlayFab Party](/build/console-features/networking/game-mesh/playfab-party-intro-networking#SuspendResume)
* [MsQuic](/build/console-features/networking/game-mesh/msquic-intro-networking#SuspendResume)
* [XCurl](/build/console-features/networking/web-requests/intro-xcurl#title-suspendresume)
* [libHttpClient（HTTP 与 WebSocket）](/build/console-features/networking/web-requests/http-networking#suspend-and-resume-with-libhttpclient)
* [WinHTTP](/build/console-features/networking/web-requests/intro-winhttp)
* [WinSock](/build/console-features/networking/game-mesh/winsock-intro-networking#SuspendResume)
* [首选本地 UDP 多人游戏端口](/build/console-features/networking/game-mesh/preferred-local-udp-multiplayer-port-networking#SuspendResume)
* [网络初始化](/build/console-features/networking/initialization-connectivity-networking#suspend-and-resume)
* [Game Chat 2](/services/xbox-services/multiplayer/chat/game-chat2/game-chat-2-intro#SuspendResume)

## XBOX One Software Development Kit 迁移

有关从先前 XBOX One Software Development Kit 文档迁移的详细信息，请参阅 [XBOX One Software Development Kit 迁移概述 (NDA 文章)](/build/console-features/networking/xdk-migration/xdk-migration-overview-networking)。该文章包含关于在 XBOX One Software Development Kit 版本与 GDK 版本之间实现通信的指导。

## 另请参阅

[网络初始化与连接性](/build/console-features/networking/initialization-connectivity-networking)

[Web 请求：HTTP 与 WebSocket](/build/console-features/networking/web-requests/http-networking)

[Windows Sockets](/build/console-features/networking/game-mesh/winsock-intro-networking)

[Game Chat 2](/services/xbox-services/multiplayer/chat/game-chat2/game-chat-2-intro)

[PlayFab Party](/build/console-features/networking/game-mesh/playfab-party-intro-networking)

[适用于 Unreal 的 PlayFab Party Online Subsystem](/build/console-features/networking/game-mesh/party-unreal-online-subsystem)

[适用于 Unity 的 PlayFab Party SDK](/build/console-features/networking/game-mesh/party-unity-plugin)

[MsQuic](/build/console-features/networking/game-mesh/msquic-intro-networking)

[XBOX Live API 入门](/services/xbox-services/fundamentals/xbox-services-api/live-gs-xbl-apis)

[首选 UDP 多人游戏端口](/build/console-features/networking/game-mesh/preferred-local-udp-multiplayer-port-networking)

[面向 Microsoft 游戏开发工具包游戏的安全游戏通信 (NDA 文章)](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/game-principles/security/communication-security/communication-security-impl/gc-secure-communication-impl)


## Related topics

- [网络](/zh-CN/build/console-features/networking/gc-networking-toc.md)
- [Microsoft 游戏开发工具包中的网络工具](/zh-CN/build/console-features/networking/tools/tools-networking-toc.md)
- [GDK 中的 Windows Sockets 简介](/zh-CN/build/console-features/networking/game-mesh/winsock-intro-networking.md)
- [Microsoft 游戏开发工具包用户模型](/zh-CN/build/core-features/common/user/gamecore-user-models.md)
- [用于 PC 游戏开发的 Visual Studio 项目模板](/zh-CN/tools/tools-pc/visualstudio/gr-vs-templates.md)
