Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Callback for received data
- /// </summary>
- private void ReceiveCallback(IAsyncResult ar)
- {
- int len = -1;
- try
- {
- len = this.GetSocket().EndReceive(ar);
- if (len <= 0)
- throw new Exception("Received " + len);
- }
- catch (Exception e)
- {
- if (ErrorEvent != null)
- ErrorEvent(this, e);
- return;
- }
- AsyncObject obj = (AsyncObject)ar.AsyncState;
- int datLen = BitConverter.ToInt32(obj.byteArray, 0);
- byte[] dataArray = new byte[datLen];
- System.Buffer.BlockCopy(obj.byteArray, 4, dataArray, 0, datLen);
- // Handle dataArray
- }
Advertisement
Add Comment
Please, Sign In to add comment