浏览代码

Don't print stacktrace when failing to bind to 1900

Bond_009 6 年之前
父节点
当前提交
783e74d9c9
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      RSSDP/SsdpCommunicationsServer.cs

+ 6 - 2
RSSDP/SsdpCommunicationsServer.cs

@@ -1,8 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Net;
 using System.Net.Http;
+using System.Net.Sockets;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
@@ -126,6 +126,10 @@ namespace Rssdp.Infrastructure
                         {
                             _BroadcastListenSocket = ListenForBroadcastsAsync();
                         }
+                        catch (SocketException)
+                        {
+                            _logger.LogError("Failed to bind to port 1900. DLNA will be unavailable");
+                        }
                         catch (Exception ex)
                         {
                             _logger.LogError(ex, "Error in BeginListeningForBroadcasts");
@@ -145,7 +149,7 @@ namespace Rssdp.Infrastructure
             {
                 if (_BroadcastListenSocket != null)
                 {
-                    _logger.LogInformation("{0} disposing _BroadcastListenSocket.", GetType().Name);
+                    _logger.LogInformation("{0} disposing _BroadcastListenSocket", GetType().Name);
                     _BroadcastListenSocket.Dispose();
                     _BroadcastListenSocket = null;
                 }