update udp sockets

This commit is contained in:
Luke Pulverenti
2016-11-14 14:48:01 -05:00
parent 75ae9f2dc1
commit 44336488f3
5 changed files with 42 additions and 37 deletions

View File

@@ -131,6 +131,7 @@ namespace Emby.Common.Implementations.Net
#else
retVal.ExclusiveAddressUse = false;
#endif
//retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(ipAddress), _LocalIP));

View File

@@ -63,7 +63,7 @@ namespace Emby.Common.Implementations.Net
}
}, state);
#else
_Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, SocketFlags.None, ref state.EndPoint, new AsyncCallback(this.ProcessResponse), state);
_Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, SocketFlags.None, ref state.EndPoint, ProcessResponse, state);
#endif
return tcs.Task;
@@ -99,7 +99,7 @@ namespace Emby.Common.Implementations.Net
_Socket.EndSend(result);
taskSource.TrySetResult(true);
}
catch (SocketException ex)
catch (Exception ex)
{
taskSource.TrySetException(ex);
}
@@ -200,13 +200,6 @@ namespace Emby.Common.Implementations.Net
{
state.TaskCompletionSource.SetCanceled();
}
catch (SocketException se)
{
if (se.SocketErrorCode != SocketError.Interrupted && se.SocketErrorCode != SocketError.OperationAborted && se.SocketErrorCode != SocketError.Shutdown)
state.TaskCompletionSource.SetException(se);
else
state.TaskCompletionSource.SetCanceled();
}
catch (Exception ex)
{
state.TaskCompletionSource.SetException(ex);