Skip to content

Commit

Permalink
Fix unhandled SocketExceptions when sending (#102)
Browse files Browse the repository at this point in the history
Fixed unhandled SocketExceptions
  • Loading branch information
Bilnord authored Nov 25, 2023
1 parent 4b42723 commit 6035f4d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions RiptideNetworking/RiptideNetworking/Transports/Udp/UdpPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,17 @@ private void Receive()
/// <param name="toEndPoint">The endpoint to send the data to.</param>
internal void Send(byte[] dataBuffer, int numBytes, IPEndPoint toEndPoint)
{
if (isRunning)
socket.SendTo(dataBuffer, numBytes, SocketFlags.None, toEndPoint);
try
{
if (isRunning)
socket.SendTo(dataBuffer, numBytes, SocketFlags.None, toEndPoint);
}
catch(SocketException)
{
// May want to consider triggering a disconnect here (perhaps depending on the type
// of SocketException)? Timeout should catch disconnections, but disconnecting
// explicitly might be better...
}
}

/// <summary>Handles received data.</summary>
Expand Down

0 comments on commit 6035f4d

Please sign in to comment.