Guest User

Untitled

a guest
Aug 3rd, 2012
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. /// <summary>
  2. /// Callback for received data
  3. /// </summary>
  4. private void ReceiveCallback(IAsyncResult ar)
  5. {
  6. int len = -1;
  7. try
  8. {
  9. len = this.GetSocket().EndReceive(ar);
  10. if (len <= 0)
  11. throw new Exception("Received " + len);
  12. }
  13. catch (Exception e)
  14. {
  15. if (ErrorEvent != null)
  16. ErrorEvent(this, e);
  17. return;
  18. }
  19. AsyncObject obj = (AsyncObject)ar.AsyncState;
  20. int datLen = BitConverter.ToInt32(obj.byteArray, 0);
  21. byte[] dataArray = new byte[datLen];
  22. System.Buffer.BlockCopy(obj.byteArray, 4, dataArray, 0, datLen);
  23. // Handle dataArray
  24. }
Advertisement
Add Comment
Please, Sign In to add comment