Interface ITransportConnection
Abstraction over a bidirectional transport connection (TCP, TLS, QUIC, test).
Encapsulates all I/O machinery: pipes, pump loops, buffer management, and flush batching. The actor writes bytes in, reads bytes out, and never touches streams or sockets directly.
Inherited Members
Namespace: Akka.IO
Assembly: Akka.dll
Syntax
public interface ITransportConnection : IAsyncDisposable
Properties
| Edit this page View SourceHasReadError
Returns true if the read pump encountered an I/O error. This is set BEFORE the input pipe writer is completed, so the actor can check it synchronously when handling a completed pipe read to distinguish error-EOF from normal EOF, even before the ReadCompleted task has been observed.
Declaration
bool HasReadError { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Input
Pipe reader for inbound data (data received from the remote peer). The actor reads from this to get Tcp.Received data.
Declaration
PipeReader Input { get; }
Property Value
| Type | Description |
|---|---|
| PipeReader |
ReadCompleted
Completes when the read pump finishes. Check IsFaulted to determine whether the read ended due to an I/O error (vs. normal EOF). The input PipeWriter is always completed WITHOUT passing the exception, so buffered data is preserved and the actor can drain it before checking this task.
Declaration
Task ReadCompleted { get; }
Property Value
| Type | Description |
|---|---|
| Task |
ReadError
The exception that caused the read pump to fail, or null if no error. Set at the same time as HasReadError.
Declaration
Exception? ReadError { get; }
Property Value
| Type | Description |
|---|---|
| Exception |
WriteCompleted
Completes when the write pump finishes (all buffered data flushed to the stream).
Declaration
Task WriteCompleted { get; }
Property Value
| Type | Description |
|---|---|
| Task |
Methods
| Edit this page View SourceAbort()
Abort: RST the connection immediately, no flush.
Declaration
void Abort()
CloseAsync()
Full close: flushes remaining writes, closes the connection.
Declaration
Task CloseAsync()
Returns
| Type | Description |
|---|---|
| Task |
FlushAsync(CancellationToken)
Explicitly flushes any buffered data to the write pump. Useful for low-throughput scenarios where writes don't fill the buffer. Under high throughput, the buffer auto-flushes at the pause threshold.
Declaration
ValueTask<FlushResult> FlushAsync(CancellationToken ct = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | ct |
Returns
| Type | Description |
|---|---|
| ValueTask<FlushResult> |
ShutdownAsync()
Half-close: flushes remaining writes, sends FIN, keeps reading.
Declaration
Task ShutdownAsync()
Returns
| Type | Description |
|---|---|
| Task |
WriteAsync(ReadOnlySequence<byte>, CancellationToken)
Writes a multi-segment sequence to the transport. Each segment is copied into the internal buffer. This avoids per-segment syscalls.
Declaration
ValueTask<FlushResult> WriteAsync(ReadOnlySequence<byte> data, CancellationToken ct = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySequence<byte> | data | |
| CancellationToken | ct |
Returns
| Type | Description |
|---|---|
| ValueTask<FlushResult> |
WriteAsync(ReadOnlyMemory<byte>, CancellationToken)
Writes data to the transport. Bytes are copied into an internal buffer and will be flushed to the underlying stream by the write pump. Returns when bytes are accepted into the buffer (not when sent on the wire). Goes async when backpressure is active (buffer full).
Declaration
ValueTask<FlushResult> WriteAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<byte> | data | |
| CancellationToken | ct |
Returns
| Type | Description |
|---|---|
| ValueTask<FlushResult> |
Edit this page