Beijing Landmark (DB11) according to the receiver.
<summary>//DB11 protocol unpacking///</summary> public class Splictprotocol {//<summar Y>/////For handling data covariance///</summary> list<byte> bytes = new list<byte> (5000); private int len =-1; <summary>//Baotou///</summary> private bool Findpackagehead = false; <summary>/////</summary> int index =-1; Public list<byte[]> splict (byte[] arr) {list<byte[]> List = new list<byte[]> (); try {if (arr! = null) {//Lock handled lock (bytes) {//Start fetching data from the queue for (int k = 0; k < arr.) Length; k++) {//queue has data byte B = arr[k]; If the maximum number of bytes received is exceeded if (<=) bytes. Count) {bytes. Clear (); }//Added to the bytes collection. ADD (b); 3. Start fetching data from the front of the collection. Find Baotou, carry out unpacking if (bytes. Count >=) {if (! Findpackagehead) {for (int i = 0; i < bytes. Count; i++) {if (bytes[i] = = 0x23 && (i + 1 &L T bytes. Count && bytes[i + 1] = = 0x23)) { index = i; Findpackagehead = true; Break } } } if (Index >-1) { 22 Data Unit Length index if (bytes. Count > Index + +) {if (len = =-1) {int xx = 0; Data length len = new Byte[2] {Bytes[index + +], Bytes[index + 23]}. Readushort (ref xx). SwapUInt16 (); } if (bytes. Count > Index + len + +) {var bb = bytes. Skip (Index). Take (+ len + 1). ToArray (); List. Add (BB); Initialize State Findpackagehead = false; Len = index =-1; Remove all data bytes. Clear (); } } } } }}} else {//thread.sleep (1); }} catch (Exception ex) {bytes. Clear (); Initialization state Findpackagehead = false; Len = index =-1; } return list; } }
DB11 TCP Data protocol unpacking and receiving main methods