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)