C# Class NetworkCommsDotNet.Tools.StreamTools

Wrapper class for writing to streams with time-outs. Used primarily to prevent stream write deadlocks.
ファイルを表示 Open project: MarcFletcher/NetworkComms.Net Class Usage Examples

Public Methods

Method Description
MD5 ( Stream streamToMD5 ) : string

Return the MD5 hash of the provided memory stream as a string. Stream position will be equal to the length of stream on return, this ensures the MD5 is consistent.

MD5 ( Stream streamToMD5, long start, int length ) : string

Return the MD5 hash of the provided memory stream as a string. Stream position will be equal to the length of stream on return, this ensures the MD5 is consistent.

MD5 ( byte bytesToMd5 ) : string

Return the MD5 hash of the provided byte array as a string

Write ( Stream inputStream, Stream destinationStream ) : double

Write the provided input stream to the destination stream

Write ( Stream inputStream, long inputStart, long inputLength, Stream destinationStream, int writeBufferSize, double timeoutMSPerKBWrite, int minTimeoutMS ) : double

Write the provided input stream to the destination stream in chunks of writeBufferSize. Throws exception if any write takes longer than timeoutPerByteWriteMS.

Write ( byte sendBuffer, int inputStart, int bufferLength, Stream destinationStream, int writeBufferSize, double timeoutMSPerKBWrite, int minTimeoutMS ) : double

Write the provided sendbuffer to the destination stream in chunks of writeBufferSize. Throws exception if any write takes longer than timeoutPerByteWriteMS.

Private Methods

Method Description
AppendStringToLogFile ( string fileName, string logString ) : void

Appends the provided logString to end of fileName.txt. If the file does not exist it will be created.

Method Details

MD5() public static method

Return the MD5 hash of the provided memory stream as a string. Stream position will be equal to the length of stream on return, this ensures the MD5 is consistent.
public static MD5 ( Stream streamToMD5 ) : string
streamToMD5 Stream The bytes which will be checksummed
return string

MD5() public static method

Return the MD5 hash of the provided memory stream as a string. Stream position will be equal to the length of stream on return, this ensures the MD5 is consistent.
public static MD5 ( Stream streamToMD5, long start, int length ) : string
streamToMD5 Stream The bytes which will be checksummed
start long The start position in the stream
length int The length in the stream to MD5
return string

MD5() public static method

Return the MD5 hash of the provided byte array as a string
public static MD5 ( byte bytesToMd5 ) : string
bytesToMd5 byte The bytes which will be checksummed
return string

Write() public static method

Write the provided input stream to the destination stream
public static Write ( Stream inputStream, Stream destinationStream ) : double
inputStream Stream Input stream containing data to send
destinationStream Stream The destination stream
return double

Write() public static method

Write the provided input stream to the destination stream in chunks of writeBufferSize. Throws exception if any write takes longer than timeoutPerByteWriteMS.
public static Write ( Stream inputStream, long inputStart, long inputLength, Stream destinationStream, int writeBufferSize, double timeoutMSPerKBWrite, int minTimeoutMS ) : double
inputStream Stream Input stream containing data to send
inputStart long The start position in inputStream
inputLength long The number of bytes to write
destinationStream Stream The destination stream
writeBufferSize int The size in bytes of each successive write, recommended 8K
timeoutMSPerKBWrite double The maximum time to allow for write to complete per KB
minTimeoutMS int The minimum time to wait per write, this takes priority over other values.
return double

Write() public static method

Write the provided sendbuffer to the destination stream in chunks of writeBufferSize. Throws exception if any write takes longer than timeoutPerByteWriteMS.
public static Write ( byte sendBuffer, int inputStart, int bufferLength, Stream destinationStream, int writeBufferSize, double timeoutMSPerKBWrite, int minTimeoutMS ) : double
sendBuffer byte Buffer containing data to write
inputStart int The start position in sendBuffer
bufferLength int The number of bytes to write
destinationStream Stream The destination stream
writeBufferSize int The size in bytes of each successive write
timeoutMSPerKBWrite double The maximum time to allow for write to complete per KB
minTimeoutMS int The minimum time to allow for any sized write
return double