Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2012
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  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.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement