Search Results for

    Show / Hide Table of Contents

    Class TcpTransportConnection

    Plaintext TCP implementation of ITransportConnection. Owns two pipes (input + output) and two pump loops that bridge them to a NetworkStream.

    Inheritance
    object
    TcpTransportConnection
    Implements
    ITransportConnection
    IAsyncDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.IO
    Assembly: Akka.dll
    Syntax
    public sealed class TcpTransportConnection : ITransportConnection, IAsyncDisposable

    Constructors

    | Edit this page View Source

    TcpTransportConnection(Socket, PipeOptions?, PipeOptions?)

    Creates a transport connection from an already-connected socket. Starts the read and write pump loops immediately.

    Declaration
    public TcpTransportConnection(Socket socket, PipeOptions? inputPipeOptions = null, PipeOptions? outputPipeOptions = null)
    Parameters
    Type Name Description
    Socket socket
    PipeOptions inputPipeOptions
    PipeOptions outputPipeOptions
    | Edit this page View Source

    TcpTransportConnection(Socket, Stream, PipeOptions?, PipeOptions?)

    Creates a transport connection from an existing stream (for TLS or testing).

    Declaration
    public TcpTransportConnection(Socket socket, Stream stream, PipeOptions? inputPipeOptions = null, PipeOptions? outputPipeOptions = null)
    Parameters
    Type Name Description
    Socket socket
    Stream stream
    PipeOptions inputPipeOptions
    PipeOptions outputPipeOptions

    Properties

    | Edit this page View Source

    HasReadError

    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
    public bool HasReadError { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Input

    Pipe reader for inbound data (data received from the remote peer). The actor reads from this to get Tcp.Received data.

    Declaration
    public PipeReader Input { get; }
    Property Value
    Type Description
    PipeReader
    | Edit this page View Source

    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
    public Task ReadCompleted { get; }
    Property Value
    Type Description
    Task
    | Edit this page View Source

    ReadError

    The exception that caused the read pump to fail, or null if no error. Set at the same time as HasReadError.

    Declaration
    public Exception? ReadError { get; }
    Property Value
    Type Description
    Exception
    | Edit this page View Source

    WriteCompleted

    Completes when the write pump finishes (all buffered data flushed to the stream).

    Declaration
    public Task WriteCompleted { get; }
    Property Value
    Type Description
    Task

    Methods

    | Edit this page View Source

    Abort()

    Abort: RST the connection immediately, no flush.

    Declaration
    public void Abort()
    | Edit this page View Source

    CloseAsync()

    Full close: flushes remaining writes, closes the connection.

    Declaration
    public Task CloseAsync()
    Returns
    Type Description
    Task
    | Edit this page View Source

    DisposeAsync()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

    Declaration
    public ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask

    A task that represents the asynchronous dispose operation.

    | Edit this page View Source

    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
    public ValueTask<FlushResult> FlushAsync(CancellationToken ct = default)
    Parameters
    Type Name Description
    CancellationToken ct
    Returns
    Type Description
    ValueTask<FlushResult>
    | Edit this page View Source

    ShutdownAsync()

    Half-close: flushes remaining writes, sends FIN, keeps reading.

    Declaration
    public Task ShutdownAsync()
    Returns
    Type Description
    Task
    | Edit this page View Source

    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
    public ValueTask<FlushResult> WriteAsync(ReadOnlySequence<byte> data, CancellationToken ct = default)
    Parameters
    Type Name Description
    ReadOnlySequence<byte> data
    CancellationToken ct
    Returns
    Type Description
    ValueTask<FlushResult>
    | Edit this page View Source

    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
    public ValueTask<FlushResult> WriteAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)
    Parameters
    Type Name Description
    ReadOnlyMemory<byte> data
    CancellationToken ct
    Returns
    Type Description
    ValueTask<FlushResult>

    Implements

    ITransportConnection
    IAsyncDisposable

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET