# otPlatTcpPlatformData


`#include <openthread/platform/tcp.h>`

Represents platform-specific data associated with a connection or a listener.

## Summary

This union is provided to add flexibility for the platform. A platform can choose to store a file descriptor (e.g., an `int` for a POSIX socket) or a pointer to an arbitrary context or state structure needed by the platform implementation.

The OpenThread stack guarantees that the `https://openthread.io/reference/union/ot-plat-tcp-platform-data` is fully cleared (all bytes set to zero) when a new listener or connection instance is initialized.

For an `https://openthread.io/reference/struct/ot-plat-tcp-listener`, the `https://openthread.io/reference/group/plat-tcp#group__plat-tcp_1gafd16312c4610ab9030c246a18213697c` call provides an opportunity for the platform to allocate or update this information. The OpenThread stack guarantees that `https://openthread.io/reference/group/plat-tcp#group__plat-tcp_1gac95d5f1159571118b59ee89c4c5d01ae` will be invoked on any previously enabled listener, providing a deterministic point for the platform implementation to perform cleanup (e.g., deallocating memory or context structures).

For an `https://openthread.io/reference/struct/ot-plat-tcp-connection`, the `https://openthread.io/reference/group/plat-tcp#group__plat-tcp_1ga3823ac8909e20feb30cd6ae110ecd597` call or the `https://openthread.io/reference/group/plat-tcp#group__plat-tcp_1ga8846079a3bf3e513d075ddf37cc12230` callback indicate when a new connection instance is provided, allowing the platform data to be initialized. The platform is responsible for cleaning up this data either before invoking `https://openthread.io/reference/group/plat-tcp#group__plat-tcp_1ga0c34e3f9a7b81dc825b09215ce366259` (which invalidates the connection) or from an `https://openthread.io/reference/group/plat-tcp#group__plat-tcp_1ga8a29c83849c4ca6620e814df4f86b800` call. The OpenThread stack guarantees that it will eventually disconnect or abort any active connection, ensuring a reliable cleanup path.

| ### Public attributes ||
|---|---|
| `https://openthread.io/reference/union/ot-plat-tcp-platform-data#unionot_plat_tcp_platform_data_1a14f69640fef1b17e4c6a043999cda2dd` | `void *` Pointer to arbitrary platform data. |
| `https://openthread.io/reference/union/ot-plat-tcp-platform-data#unionot_plat_tcp_platform_data_1aec7883be4df92fba7ea88337e0ea33e0` | `int` A value (like a file descriptor). |

## Public attributes

### mContext

```
void * mContext
```
Pointer to arbitrary platform data.

### mDescriptor

```
int mDescriptor
```
A value (like a file descriptor).

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).