aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/Net/SocketFactory.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-03-29 02:53:26 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-03-29 02:53:26 -0400
commite632f4aef3841a3f0d8efd2dbb930811dca19c1e (patch)
treecf9775cbfcc4d032c2517de5213a6e9a2ec750e8 /Emby.Common.Implementations/Net/SocketFactory.cs
parentf6b94af438da8f8d3b3760c3e67eb24b09bafbfd (diff)
3.2.9.2
Diffstat (limited to 'Emby.Common.Implementations/Net/SocketFactory.cs')
-rw-r--r--Emby.Common.Implementations/Net/SocketFactory.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Emby.Common.Implementations/Net/SocketFactory.cs b/Emby.Common.Implementations/Net/SocketFactory.cs
index 1fd367afb..39f236afa 100644
--- a/Emby.Common.Implementations/Net/SocketFactory.cs
+++ b/Emby.Common.Implementations/Net/SocketFactory.cs
@@ -70,11 +70,23 @@ namespace Emby.Common.Implementations.Net
{
if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", "remotePort");
- var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
-
+ var addressFamily = remoteAddress.AddressFamily == IpAddressFamily.InterNetwork
+ ? AddressFamily.InterNetwork
+ : AddressFamily.InterNetworkV6;
+
+ var retVal = new Socket(addressFamily, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
+
try
{
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+ }
+ catch (SocketException)
+ {
+ // This is not supported on all operating systems (qnap)
+ }
+
+ try
+ {
return new UdpSocket(retVal, new IpEndPointInfo(remoteAddress, remotePort));
}
catch