Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 3rd, 2012  |  syntax: C#  |  size: 1.06 KB  |  hits: 154  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         while (continueReceivingChallenges)
  2.         {
  3.             try
  4.             {
  5.                 Byte[] receivedBytes = client.Receive(ref remoteIp);
  6.  
  7.                 ipAddress = Encoding.ASCII.GetString(receivedBytes);
  8.  
  9.                 // Uncomment the following break if the code that calls
  10.                 // the method this belongs to expects the function to return
  11.                 // (and the thread to end) after receiving a message
  12.                 // break;
  13.             }
  14.             catch (SocketException ex)
  15.             {
  16.                 if (ex.SocketErrorCode == SocketError.TimedOut)
  17.                 {
  18.                     // In order to reproduce the original UdpClient behavior
  19.                     // of waiting forever until a message comes in, you'll
  20.                     // want to just ignore the timeout exception instead of
  21.                     // re-throwing it.
  22.                     //throw new Exception("No message where recieved");
  23.                 }
  24.                 else
  25.                 {
  26.                     throw new Exception("Unexpected Socket error", ex);
  27.                 }
  28.             }
  29.         }