Xceed .NET Libraries Documentation
Xceed.SSH.Client Assembly / Xceed.SSH.Client Namespace / SFtpSession Class / ComputeStreamBufferSize Method


In This Topic
    ComputeStreamBufferSize Method (SFtpSession)
    In This Topic
    Computes the optimal buffer size for SFtp file transfers on the specified stream.
    Overload List
    OverloadDescription
    Computes the optimal buffer size for SFtp file transfers on the specified stream.nullSSH  
     
    Remarks

    This method is useful when performing manual SFtp file transfers (see example below). The method is used by SFtpFile when it is used as a destination for a file transfer.

    If stream is null or is not a SFtp write stream, a good buffer size will still be computed without error as the stream information is just part of the computation. It is fine to use the returned value in that situation.

    SSH has overhead and several rules where the server defines a maximum logical packet size.

    Any reasonable buffer size can be used when writing to a SFtp stream, it will work. However, using a value too small will generate more overhead than needed. Using a value that is too large will force the component to split the data into several packets and increase overhead as well.

    This method computes the optimal buffer size for the specified SFtp stream. It takes into account the effective overhead packets will take and computes a value that will make it so that every call to Stream.Write() will end up creating the biggest SSH packet allowed by the server that does not generate extra overhead.

    This provides the best throughput in a file transfer where a SFtp stream is the destination.

    Example
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Standard: netstandard2.0, netstandard2.1

    .NET Framework: net20, net35, net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also