Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Catch exceptions from UdpClient.Recieve #107

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Open.Nat/Discovery/Searcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,18 @@ private void Receive(CancellationToken cancelationToken)

var localHost = ((IPEndPoint)client.Client.LocalEndPoint).Address;
var receivedFrom = new IPEndPoint(IPAddress.None, 0);
var buffer = client.Receive(ref receivedFrom);
var device = AnalyseReceivedResponse(localHost, buffer, receivedFrom);
try
{
var buffer = client.Receive(ref receivedFrom);
var device = AnalyseReceivedResponse(localHost, buffer, receivedFrom);

if (device != null) RaiseDeviceFound(device);
if (device != null) RaiseDeviceFound(device);
}
catch(Exception e)
ogonzalez-sd marked this conversation as resolved.
Show resolved Hide resolved
{
NatDiscoverer.TraceSource.LogError("Error receiving {0} - Details:", GetType().Name);
ogonzalez-sd marked this conversation as resolved.
Show resolved Hide resolved
NatDiscoverer.TraceSource.LogError(e.ToString());
}
}
}

Expand Down