資源簡介
最近項目要用到Socket,遇到一些坑,比如頻繁發(fā)消息 收消息,會產(chǎn)生粘包拆包等問題,還有斷線重連的問題

代碼片段和文件信息
#region?Copyright?notice?and?license
//?Protocol?Buffers?-?Google‘s?data?interchange?format
//?Copyright?2008?Google?Inc.??All?rights?reserved.
//?https://developers.google.com/protocol-buffers/
//
//?Redistribution?and?use?in?source?and?binary?forms?with?or?without
//?modification?are?permitted?provided?that?the?following?conditions?are
//?met:
//
//?????*?Redistributions?of?source?code?must?retain?the?above?copyright
//?notice?this?list?of?conditions?and?the?following?disclaimer.
//?????*?Redistributions?in?binary?form?must?reproduce?the?above
//?copyright?notice?this?list?of?conditions?and?the?following?disclaimer
//?in?the?documentation?and/or?other?materials?provided?with?the
//?distribution.
//?????*?Neither?the?name?of?Google?Inc.?nor?the?names?of?its
//?contributors?may?be?used?to?endorse?or?promote?products?derived?from
//?this?software?without?specific?prior?written?permission.
//
//?THIS?SOFTWARE?IS?PROVIDED?BY?THE?COPYRIGHT?HOLDERS?AND?CONTRIBUTORS
//?“AS?IS“?AND?ANY?EXPRESS?OR?IMPLIED?WARRANTIES?INCLUDING?BUT?NOT
//?LIMITED?TO?THE?IMPLIED?WARRANTIES?OF?MERCHANTABILITY?AND?FITNESS?FOR
//?A?PARTICULAR?PURPOSE?ARE?DISCLAIMED.?IN?NO?EVENT?SHALL?THE?COPYRIGHT
//?OWNER?OR?CONTRIBUTORS?BE?LIABLE?FOR?ANY?DIRECT?INDIRECT?INCIDENTAL
//?SPECIAL?EXEMPLARY?OR?CONSEQUENTIAL?DAMAGES?(INCLUDING?BUT?NOT
//?LIMITED?TO?PROCUREMENT?OF?SUBSTITUTE?GOODS?OR?SERVICES;?LOSS?OF?USE
//?DATA?OR?PROFITS;?OR?BUSINESS?INTERRUPTION)?HOWEVER?CAUSED?AND?ON?ANY
//?THEORY?OF?LIABILITY?WHETHER?IN?CONTRACT?STRICT?LIABILITY?OR?TORT
//?(INCLUDING?NEGLIGENCE?OR?OTHERWISE)?ARISING?IN?ANY?WAY?OUT?OF?THE?USE
//?OF?THIS?SOFTWARE?EVEN?IF?ADVISED?OF?THE?POSSIBILITY?OF?SUCH?DAMAGE.
#endregion
using?System;
namespace?Google.Protobuf
{
????///?
????///?Provides?a?utility?routine?to?copy?small?arrays?much?more?quickly?than?Buffer.BlockCopy
????///?
????internal?static?class?ByteArray
????{
????????///?
????????///?The?threshold?above?which?you?should?use?Buffer.BlockCopy?rather?than?ByteArray.Copy
????????///?
????????private?const?int?CopyThreshold?=?12;
????????///?
????????///?Determines?which?copy?routine?to?use?based?on?the?number?of?bytes?to?be?copied.
????????///?
????????internal?static?void?Copy(byte[]?src?int?srcOffset?byte[]?dst?int?dstOffset?int?count)
????????{
????????????if?(count?>?CopyThreshold)
????????????{
????????????????Buffer.BlockCopy(src?srcOffset?dst?dstOffset?count);
????????????}
????????????else
????????????{
????????????????int?stop?=?srcOffset?+?count;
????????????????for?(int?i?=?srcOffset;?i?????????????????{
????????????????????dst[dstOffset++]?=?src[i];
????????????????}
????????????}
????????}
????????///?
????????///?Reverses?the?order?of?bytes?in?the?array
????????///?
????????internal?static?void?Reverse(byte[]?bytes)
????????{
????????????for?(int?first?=?0
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-02-21?12:10??Socket_Protobuff\
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\.vs\
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\.vs\Socket_Protobuff\
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\.vs\Socket_Protobuff\v15\
?????文件??????120832??2019-02-21?12:10??Socket_Protobuff\.vs\Socket_Protobuff\v15\.suo
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\.vs\Socket_Protobuff\v15\Server\
?????目錄???????????0??2019-02-21?12:06??Socket_Protobuff\.vs\Socket_Protobuff\v15\Server\sqlite3\
?????文件???????????0??2018-07-20?12:14??Socket_Protobuff\.vs\Socket_Protobuff\v15\Server\sqlite3\db.lock
?????文件??????749568??2018-07-20?15:14??Socket_Protobuff\.vs\Socket_Protobuff\v15\Server\sqlite3\storage.ide
?????文件???????32768??2019-02-21?12:06??Socket_Protobuff\.vs\Socket_Protobuff\v15\Server\sqlite3\storage.ide-shm
?????文件??????774592??2019-02-21?12:10??Socket_Protobuff\.vs\Socket_Protobuff\v15\Server\sqlite3\storage.ide-wal
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\Assets\
?????文件???????13472??2018-07-20?13:48??Socket_Protobuff\Assets\DEMO.unity
?????文件?????????174??2018-07-20?13:44??Socket_Protobuff\Assets\DEMO.unity.me
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\Assets\Plugins\
?????文件?????????191??2018-07-20?12:16??Socket_Protobuff\Assets\Plugins.me
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\Assets\Plugins\Google.Protobuf\
?????文件?????????191??2018-07-20?12:16??Socket_Protobuff\Assets\Plugins\Google.Protobuf.me
?????文件????????3236??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\ByteArray.cs
?????文件?????????274??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\ByteArray.cs.me
?????文件???????13162??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\ByteString.cs
?????文件?????????274??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\ByteString.cs.me
?????文件???????48052??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\CodedInputStream.cs
?????文件?????????274??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\CodedInputStream.cs.me
?????文件???????10658??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\CodedOutputStream.ComputeSize.cs
?????文件?????????274??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\CodedOutputStream.ComputeSize.cs.me
?????文件???????28074??2018-07-17?14:34??Socket_Protobuff\Assets\Plugins\Google.Protobuf\CodedOutputStream.cs
?????文件?????????274??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\CodedOutputStream.cs.me
?????目錄???????????0??2019-02-21?12:05??Socket_Protobuff\Assets\Plugins\Google.Protobuf\Collections\
?????文件?????????200??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\Collections.me
?????文件???????29735??2018-05-02?17:10??Socket_Protobuff\Assets\Plugins\Google.Protobuf\Collections\MapField.cs
............此處省略809個文件信息
評論
共有 條評論