# otTcpCircularSendBuffer Struct Reference

# otTcpCircularSendBuffer


`#include <openthread/tcp_ext.h>`

Represents a circular send buffer for use with a TCP endpoint.

## Summary

Using a circular send buffer is optional. Applications can use a TCP endpoint to send data by managing otLinkedBuffers directly. However, some applications may find it more convenient to have a circular send buffer; such applications can call [otTcpCircularSendBufferWrite()](https://openthread.io/reference/group/api-tcp-ext#group__api-tcp-ext_1gad1a45cbf68b7d09cc5692a1ead5426f1) to "attach" a circular send buffer to a TCP endpoint and send out data on that TCP endpoint, relying on the circular send buffer to manage the underlying otLinkedBuffers.

[otTcpCircularSendBuffer](https://openthread.io/reference/struct/ot-tcp-circular-send-buffer) is implemented on top of the otLinkedBuffer-based API provided by an [otTcpEndpoint](https://openthread.io/reference/struct/ot-tcp-endpoint). Once attached to an [otTcpEndpoint](https://openthread.io/reference/struct/ot-tcp-endpoint), an [otTcpCircularSendBuffer](https://openthread.io/reference/struct/ot-tcp-circular-send-buffer) performs all the work of managing otLinkedBuffers for the connection. This means that, once an [otTcpCircularSendBuffer](https://openthread.io/reference/struct/ot-tcp-circular-send-buffer) is attached to an [otTcpEndpoint](https://openthread.io/reference/struct/ot-tcp-endpoint), the application should not call [otTcpSendByReference()](https://openthread.io/reference/group/api-tcp#group__api-tcp_1gaa75f4bd44478f8a09a41b49544a96dfb) or [otTcpSendByExtension()](https://openthread.io/reference/group/api-tcp#group__api-tcp_1gaf4c8ad89d113b0b40778be6ca5d3cde8) on that [otTcpEndpoint](https://openthread.io/reference/struct/ot-tcp-endpoint). Instead, the application should use [otTcpCircularSendBufferWrite()](https://openthread.io/reference/group/api-tcp-ext#group__api-tcp-ext_1gad1a45cbf68b7d09cc5692a1ead5426f1) to add data to the send buffer.

The [otTcpForwardProgress()](https://openthread.io/reference/group/api-tcp#group__api-tcp_1ga69935ba978a5984e8b38b5fc8854c6fb) callback is the intended way for users to learn when space becomes available in the circular send buffer. On an [otTcpEndpoint](https://openthread.io/reference/struct/ot-tcp-endpoint) to which an [otTcpCircularSendBuffer](https://openthread.io/reference/struct/ot-tcp-circular-send-buffer) is attached, the application MUST install an [otTcpForwardProgress()](https://openthread.io/reference/group/api-tcp#group__api-tcp_1ga69935ba978a5984e8b38b5fc8854c6fb) callback and call [otTcpCircularSendBufferHandleForwardProgress()](https://openthread.io/reference/group/api-tcp-ext#group__api-tcp-ext_1gae4634389a476f7f4db78bbc69bd00058) on the attached [otTcpCircularSendBuffer](https://openthread.io/reference/struct/ot-tcp-circular-send-buffer) at the start of the callback function. It is recommended that the user NOT install an [otTcpSendDone()](https://openthread.io/reference/group/api-tcp#group__api-tcp_1gab49b3db0f5d27c85e72672468b6c425b) callback, as all management of otLinkedBuffers is handled by the circular send buffer.

The application should not inspect the fields of this structure directly; it should only interact with it via the TCP Circular Send Buffer API functions whose signature are provided in this file.

| ### Public attributes ||
|---|---|
| `https://openthread.io/reference/struct/ot-tcp-circular-send-buffer#structot_tcp_circular_send_buffer_1a733c7cc1b1404e8c5aa595b337b67b62` | `size_t` Length of the circular send buffer. |
| `https://openthread.io/reference/struct/ot-tcp-circular-send-buffer#structot_tcp_circular_send_buffer_1a57bc4ca74e1b24d17b7f55023cb697a3` | `size_t` Number of bytes stored in the send buffer. |
| `https://openthread.io/reference/struct/ot-tcp-circular-send-buffer#structot_tcp_circular_send_buffer_1adc5672659922afcd120699557cc3a002` | `uint8_t *` Pointer to data in the circular send buffer. |
| `https://openthread.io/reference/struct/ot-tcp-circular-send-buffer#structot_tcp_circular_send_buffer_1a6a7f7230edc3c191a120ec60538adcca` | `uint8_t` |
| `https://openthread.io/reference/struct/ot-tcp-circular-send-buffer#structot_tcp_circular_send_buffer_1a4d8d7d62e4d13a7e8484abb94d9ed802[2]` | `https://openthread.io/reference/struct/ot-linked-buffer` |
| `https://openthread.io/reference/struct/ot-tcp-circular-send-buffer#structot_tcp_circular_send_buffer_1afceae2326a68baec88d919e90a56ba77` | `size_t` Index of the first valid byte in the send buffer. |

## Public attributes

### mCapacity

```
size_t otTcpCircularSendBuffer::mCapacity
```
Length of the circular send buffer.

### mCapacityUsed

```
size_t otTcpCircularSendBuffer::mCapacityUsed
```
Number of bytes stored in the send buffer.

### mDataBuffer

```
uint8_t * otTcpCircularSendBuffer::mDataBuffer
```
Pointer to data in the circular send buffer.

### mFirstSendLinkIndex

```
uint8_t otTcpCircularSendBuffer::mFirstSendLinkIndex
```

### mSendLinks

```
otLinkedBuffer otTcpCircularSendBuffer::mSendLinks[2]
```

### mStartIndex

```
size_t otTcpCircularSendBuffer::mStartIndex
```
Index of the first valid byte in the send buffer.

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