From 8ee4da0f0fcd8f20517701d7cf155d32a328996f Mon Sep 17 00:00:00 2001 From: Andrey Lomakin Date: Thu, 14 May 2020 13:40:24 +0300 Subject: [PATCH] SIO_UDP_CONNRESET: prevent exception throwing on unsupported platforms --- RtspClientSharp/Utils/NetworkClientFactory.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/RtspClientSharp/Utils/NetworkClientFactory.cs b/RtspClientSharp/Utils/NetworkClientFactory.cs index c402b81..35d831a 100644 --- a/RtspClientSharp/Utils/NetworkClientFactory.cs +++ b/RtspClientSharp/Utils/NetworkClientFactory.cs @@ -1,4 +1,5 @@ -using System.Net.Sockets; +using System; +using System.Net.Sockets; namespace RtspClientSharp.Utils { @@ -27,8 +28,17 @@ public static Socket CreateUdpClient() ReceiveBufferSize = UdpReceiveBufferDefaultSize, DualMode = true }; - socket.IOControl((IOControlCode)SIO_UDP_CONNRESET, EmptyOptionInValue, null); + + try + { + socket.IOControl((IOControlCode)SIO_UDP_CONNRESET, EmptyOptionInValue, null); + } + catch (PlatformNotSupportedException) + { + + } + return socket; } } -} \ No newline at end of file +}