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 otPlatTcpPlatformData is fully cleared (all bytes set to zero) when a new listener or connection instance is initialized.
For an otPlatTcpListener, the otPlatTcpEnableListener() call provides an opportunity for the platform to allocate or update this information. The OpenThread stack guarantees that otPlatTcpDisableListener() 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 otPlatTcpConnection, the otPlatTcpConnect() call or the otPlatTcpAccept() 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 otPlatTcpHandleDisconnected() (which invalidates the connection) or from an otPlatTcpAbort() call. The OpenThread stack guarantees that it will eventually disconnect or abort any active connection, ensuring a reliable cleanup path.
Public attributes |
|
|---|---|
mContext
|
void *
Pointer to arbitrary platform data.
|
mDescriptor
|
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. For more information, or to contribute to our documentation, refer to Resources.