Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (continueReceivingChallenges)
- {
- try
- {
- Byte[] receivedBytes = client.Receive(ref remoteIp);
- ipAddress = Encoding.ASCII.GetString(receivedBytes);
- // Uncomment the following break if the code that calls
- // the method this belongs to expects the function to return
- // (and the thread to end) after receiving a message
- // break;
- }
- catch (SocketException ex)
- {
- if (ex.SocketErrorCode == SocketError.TimedOut)
- {
- // In order to reproduce the original UdpClient behavior
- // of waiting forever until a message comes in, you'll
- // want to just ignore the timeout exception instead of
- // re-throwing it.
- //throw new Exception("No message where recieved");
- }
- else
- {
- throw new Exception("Unexpected Socket error", ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement