# ConnectionFrameHelper

Package: [Microsoft.Orleans.Core](/orleans/docs/api/csharp/microsoft.orleans.core/) 10.0.0

[NuGet package](https://www.nuget.org/packages/Microsoft.Orleans.Core) | [Source](https://github.com/dotnet/orleans/blob/c9649c32492ebefacecd89d6fdef918adede6cdf/src/Orleans.Core/Networking/ConnectionFrameHelper.cs#L29)

```csharp
public static class ConnectionFrameHelper
```

Provides framing utilities for connection middleware authors. 

Wire format per frame: [4-byte LE length] [1-byte frame type] [payload]. The length field equals 1 + payload.Length.

Connection middlewares should follow the `Microsoft.AspNetCore.Connections.ConnectionDelegate` pipeline pattern (like TLS) and register via `SiloConnectionOptions` or `ClientConnectionOptions`. Use these helpers for structured frame I/O within your middleware.

This helper is optional. Middleware authors who need custom protocols can read/write directly from `context.Transport.Input` (PipeReader) and `context.Transport.Output` (PipeWriter) without using this class.

## Methods

- [ReadFrameAsync(ConnectionContext, CancellationToken, int)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/methods/readframeasync-microsoft-aspnetcore-connections-connectioncontext-system-threadi-6e73b438/)
- [ReadLengthPrefixedString(byte[], int)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/methods/readlengthprefixedstring-byte-array-1-ref-int-970582d4/)
- [WriteFrameAsync(ConnectionContext, byte, Action&lt;IBufferWriter&lt;byte&gt;&gt;, CancellationToken)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/methods/writeframeasync-microsoft-aspnetcore-connections-connectioncontext-byte-system-a-84768933/)
- [WriteFrameAsync(ConnectionContext, byte, byte[], CancellationToken)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/methods/writeframeasync-microsoft-aspnetcore-connections-connectioncontext-byte-byte-arr-b67188ba/)
- [WriteLengthPrefixedString(IBufferWriter&lt;byte&gt;, string)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/methods/writelengthprefixedstring-system-buffers-ibufferwriter-byte-string-993def94/)

## Fields

- [DefaultMaxFrameLength](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/fields/defaultmaxframelength-9e4c614b/)
- [FramePrefixSize](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.runtime.messaging.connectionframehelper/fields/frameprefixsize-916b47ad/)
