public class SocketPacket { public System.Net.Sockets.Socket thisSocket; public byte[] dataBuffer = new byte[64]; } /// <summary> /// receiving data /// </summary> byte[] concat = new byte[0]; public void OnDataReceived(IAsyncResult asyn) { try { Console.Write("-"); i = i + 64; byte[] src = { 0xAA, 0x55 }; SocketPacket theSockId = (SocketPacket)asyn.AsyncState; int iRx = theSockId.thisSocket.EndReceive(asyn); Array.Resize(ref concat, i); Array.Copy(theSockId.dataBuffer, 0, concat, concat.Length - 64,64); int result = BytePharse.ByteSearch(theSockId.dataBuffer, src, 0); if (result != -1) { Console.WriteLine("\nCompleted, Press Enter to Exit..."); BytePharse.pharseData(concat); Program.ev.Set(); } int duzina = concat.Length; WaitForData(); } catch (SocketException se) { Console.WriteLine(se.Message + "," + se.ErrorCode.ToString()); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)