Xceed .NET Libraries Documentation
Xceed.SSH.Client Assembly / Xceed.SSH.Client Namespace / SFtpSession Class / ComputeStreamBufferSize Method / ComputeStreamBufferSize(Stream) Method
Example


In This Topic
    ComputeStreamBufferSize(Stream) Method
    In This Topic
    Computes the optimal buffer size for SFtp file transfers on the specified stream.nullSSH
    Syntax
    'Declaration
     
    
    Public Overloads Function ComputeStreamBufferSize( _
       ByVal stream As Stream _
    ) As Integer
    'Usage
     
    
    Dim instance As SFtpSession
    Dim stream As Stream
    Dim value As Integer
     
    value = instance.ComputeStreamBufferSize(stream)
    public int ComputeStreamBufferSize( 
       Stream stream
    )

    Parameters

    stream

    Return Value

    An Integer value that represents the optimal buffer size for SFtp file transfers on the specified stream.
    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.

    streamnullSSH
    Example
    null
    SSH
    Example
    null
    SSH
    Supported Frameworks
    stream
    See Also