Streamsendwrapper Class (Networkcomms 2.3.1 source knowledge and learning)

Source: Internet
Author: User

Networkcomms.net2.3.1 Open source version, based on GPL V3 protocol. Because the 3.x version of the source code can not be published, so based on this version of learning.3. There are many improvements and bug fixes in the X version, and there is little difference in how to use them. /*Please note that the following code is required to comply with the GPLV3 protocol*/usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.IO;namespacedpsbase{///send all or part of the data stream        Public classstreamsendwrapper:idisposable {ObjectStreamlocker =New Object();  PublicThreadsafestream Threadsafestream {Get;Set; }  Public LongStart {Get;Private Set; }  Public LongLength {Get;Private Set; }  PublicStreamsendwrapper (Threadsafestream stream) { This. Threadsafestream =stream;  This. Start =0;  This. Length =Stream.        Length; }                PublicStreamsendwrapper (Threadsafestream Stream,LongStartLonglength) {            if(Start <0)                Throw NewException ("provided start value cannot is less than 0."); if(Length <0)                Throw NewException ("provided length value cannot is less than 0.");  This. Threadsafestream =stream;  This. Start =start;  This. Length =length; }        /// <summary>        ///Return the MD5 for the specific part of the stream only. ///returns the MD5 value of the specified part of the data flow/// </summary>        /// <returns></returns>         Public stringmd5checksum () {using(MemoryStream ms =NewMemoryStream ()) {Threadsafestream.copyto (MS, Start, Length,8000);#ifWindows_phoneusing(varMD5 =Newdpsbase.md5managed ()) {#else                using(varMD5 =System.Security.Cryptography.MD5.Create ()) {#endif                    returnBitconverter.tostring (Md5.computehash (ms)). Replace ("-",""); }            }        }          Public voidDispose () {threadsafestream.dispose (); }}} http://Www.cnblogs.com/networkcommshttp//www.networkcoms.cn Edit

Streamsendwrapper Class (Networkcomms 2.3.1 source knowledge and learning)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.