> ## 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.

# XGameStreamingGetClientIPAddress

> XGameStreamingGetClientIPAddress

# XGameStreamingGetClientIPAddress

> [!NOTE]
>
> **Deprecated.** This API is deprecated as of the 2604 GDK release and will be removed in a future GDK release. On the current XBOX Cloud Gaming streaming stack, this API is non-functional and returns `E_GAMESTREAMING_NO_DATA` on success.
>
> If your title needs to determine whether it's running on an XBOX Game Streaming server, or needs the user's approximate geographic location, use [XSTS token claims](/services/xbox-services/fundamentals/s2s-auth-calls/service-authentication/security-tokens/live-token-claims) instead.

This API returns an IP address for the end user client device that is being used to stream content via the xbox game streaming service. This API and associated information should only be used when complying with Microsoft standard privacy guidelines with respect to informing end users of the information collection. If you have any questions or concerns regarding the compliant usage of this API reach out to your Microsoft representative.

## Syntax

```cpp theme={null}
HRESULT XGameStreamingGetClientIPAddress(  
         XGameStreamingClientId client,  
         size_t ipAddressSize,  
         char* ipAddress  
)  
```

### Parameters

*client*   \_In\_\
Type: XGameStreamingClientId

The streaming client that is being queried.

*ipAddressSize*   \_In\_\
Type: size\_t

The maximum size of the `ipAddress` buffer that is being provided. Typically the value of this should just be the **ClientIPAddressMaxBytes**.

*ipAddress*   \_Out\_writes\_z\_(ipAddressSize)\
Type: char\*

The buffer that will be populated with the IP address of the specified client.

### Return value

Type: HRESULT

Returns **S\_OK** if successful; otherwise, returns an error code.

#### Potential Errors

| Error Code | Error Value | Reason for Error |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | The XGameStreaming runtime has not been initialized. Call [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize) before calling other APIs. |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | The specified client is not connected. |
| E\_GAMESTREAMING\_NO\_DATA | 0x89245402 | The requested data is not available. The data may be available later. |
| E\_NOT\_SUFFICIENT\_BUFFER | 0x7A | *ipAddress* is not large enough to hold the IP address and null terminating character. |

For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

The `ipAddress` can be either an IPv4 address (1.2.3.4) or an IPv6 address (1:2:3:4:5:6:7:8). [ParseNetworkString](https://learn.microsoft.com/windows/win32/api/iphlpapi/nf-iphlpapi-parsenetworkstring) can be used to parse the string if desired.

The IP address returned is what the XBOX has received from the streaming client. If the streaming client is using a VPN or is behind a NAT then utilizing the IP address for geolocation may have issues.

> [!NOTE]
>
> Private IP addresses may be returned during development or remote play scenarios where the streaming client and the XBOX are on the same private network.

## Example

```C++ theme={null}
void GameStreamingClientManager::GetClientIPAddress(XGameStreamingClientId client)
{
    // Create the output buffer for the IP address
    char ipAddress[ClientIPAddressMaxBytes]; 

    // Get the IP address of the client 
    HRESULT hr = XGameStreamingGetClientIPAddress(client, ClientIPAddressMaxBytes, ipAddress); 

    if (SUCCEEDED(hr)) 
    { 
        // Game logic to use IP address
    } 
    else if (hr == E_GAMESTREAMING_CLIENT_NO_DATA) 
    { 
        // Game logic handles no data on client case 
    } 
    else 
    { 
        // In case of error just log and proceed as if there was no data 
        LogFormat(L"XGameStreamingGetClientIPAddress failed %x", hr); 
    } 
}
```

## Requirements

**Header:** xgamestreaming.h\
**Library:** xgameruntime.lib\
**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)


## Related topics

- [XGameStreamingClientProperty](/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
- [Development Best Practices for Xbox Game Streaming](/build/core-features/common/game-streaming/game-streaming-optimizing-your-game.md)
- [XGameStreaming (API contents)](/reference/system/xgamestreaming/xgamestreaming_members.md)
- [XGameStreamingGetClients](/reference/system/xgamestreaming/functions/xgamestreaminggetclients.md)
- [XGameStreamingGetClientCount](/reference/system/xgamestreaming/functions/xgamestreaminggetclientcount.md)
