aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/Net
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-12-07 15:02:34 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-12-07 15:02:34 -0500
commit0130209cdce07dc042b075c6cf972a7eb1339861 (patch)
treeaede8b599fe887f206fbe703e023ed3677ea5f4f /Emby.Common.Implementations/Net
parent20c249979759a836f63a886a871db69ceaeb757e (diff)
improve ipv6 error handling
Diffstat (limited to 'Emby.Common.Implementations/Net')
-rw-r--r--Emby.Common.Implementations/Net/NetSocket.cs7
-rw-r--r--Emby.Common.Implementations/Net/SocketAcceptor.cs6
-rw-r--r--Emby.Common.Implementations/Net/SocketFactory.cs14
3 files changed, 11 insertions, 16 deletions
diff --git a/Emby.Common.Implementations/Net/NetSocket.cs b/Emby.Common.Implementations/Net/NetSocket.cs
index 62ca3d6ac..bc012dfe2 100644
--- a/Emby.Common.Implementations/Net/NetSocket.cs
+++ b/Emby.Common.Implementations/Net/NetSocket.cs
@@ -13,7 +13,9 @@ namespace Emby.Common.Implementations.Net
public Socket Socket { get; private set; }
private readonly ILogger _logger;
- public NetSocket(Socket socket, ILogger logger)
+ public bool DualMode { get; private set; }
+
+ public NetSocket(Socket socket, ILogger logger, bool isDualMode)
{
if (socket == null)
{
@@ -26,6 +28,7 @@ namespace Emby.Common.Implementations.Net
Socket = socket;
_logger = logger;
+ DualMode = isDualMode;
}
public IpEndPointInfo LocalEndPoint
@@ -81,7 +84,7 @@ namespace Emby.Common.Implementations.Net
private SocketAcceptor _acceptor;
public void StartAccept(Action<ISocket> onAccept, Func<bool> isClosed)
{
- _acceptor = new SocketAcceptor(_logger, Socket, onAccept, isClosed);
+ _acceptor = new SocketAcceptor(_logger, Socket, onAccept, isClosed, DualMode);
_acceptor.StartAccept();
}
diff --git a/Emby.Common.Implementations/Net/SocketAcceptor.cs b/Emby.Common.Implementations/Net/SocketAcceptor.cs
index bddb7a079..d4c6d33e5 100644
--- a/Emby.Common.Implementations/Net/SocketAcceptor.cs
+++ b/Emby.Common.Implementations/Net/SocketAcceptor.cs
@@ -11,8 +11,9 @@ namespace Emby.Common.Implementations.Net
private readonly Socket _originalSocket;
private readonly Func<bool> _isClosed;
private readonly Action<ISocket> _onAccept;
+ private readonly bool _isDualMode;
- public SocketAcceptor(ILogger logger, Socket originalSocket, Action<ISocket> onAccept, Func<bool> isClosed)
+ public SocketAcceptor(ILogger logger, Socket originalSocket, Action<ISocket> onAccept, Func<bool> isClosed, bool isDualMode)
{
if (logger == null)
{
@@ -34,6 +35,7 @@ namespace Emby.Common.Implementations.Net
_logger = logger;
_originalSocket = originalSocket;
_isClosed = isClosed;
+ _isDualMode = isDualMode;
_onAccept = onAccept;
}
@@ -115,7 +117,7 @@ namespace Emby.Common.Implementations.Net
if (acceptSocket != null)
{
//ProcessAccept(acceptSocket);
- _onAccept(new NetSocket(acceptSocket, _logger));
+ _onAccept(new NetSocket(acceptSocket, _logger, _isDualMode));
}
// Accept the next connection request
diff --git a/Emby.Common.Implementations/Net/SocketFactory.cs b/Emby.Common.Implementations/Net/SocketFactory.cs
index 79310e017..1f41ffff5 100644
--- a/Emby.Common.Implementations/Net/SocketFactory.cs
+++ b/Emby.Common.Implementations/Net/SocketFactory.cs
@@ -46,21 +46,11 @@ namespace Emby.Common.Implementations.Net
socket.DualMode = true;
}
- return new NetSocket(socket, _logger);
+ return new NetSocket(socket, _logger, dualMode);
}
catch (SocketException ex)
{
- if (dualMode)
- {
- _logger.Error("Error creating dual mode socket: {0}. Will retry with ipv4-only.", ex.SocketErrorCode);
-
- if (ex.SocketErrorCode == SocketError.AddressFamilyNotSupported)
- {
- return CreateSocket(IpAddressFamily.InterNetwork, socketType, protocolType, false);
- }
- }
-
- throw;
+ throw new SocketCreateException(ex.SocketErrorCode.ToString(), ex);
}
}