update socket methods

This commit is contained in:
Luke Pulverenti 2017-03-26 19:36:52 -04:00
parent 85f4f8dbc9
commit 5477bb95d9

View File

@ -49,7 +49,7 @@ namespace Emby.Common.Implementations.Net
private void InitReceiveSocketAsyncEventArgs()
{
var receiveBuffer = new byte[8192];
var receiveBuffer = new byte[81920];
_receiveSocketAsyncEventArgs.SetBuffer(receiveBuffer, 0, receiveBuffer.Length);
_receiveSocketAsyncEventArgs.Completed += _receiveSocketAsyncEventArgs_Completed;
@ -128,11 +128,18 @@ namespace Emby.Common.Implementations.Net
_receiveSocketAsyncEventArgs.RemoteEndPoint = receivedFromEndPoint;
_currentReceiveTaskCompletionSource = tcs;
var willRaiseEvent = _Socket.ReceiveFromAsync(_receiveSocketAsyncEventArgs);
if (!willRaiseEvent)
try
{
_receiveSocketAsyncEventArgs_Completed(this, _receiveSocketAsyncEventArgs);
var willRaiseEvent = _Socket.ReceiveFromAsync(_receiveSocketAsyncEventArgs);
if (!willRaiseEvent)
{
_receiveSocketAsyncEventArgs_Completed(this, _receiveSocketAsyncEventArgs);
}
}
catch (Exception ex)
{
tcs.TrySetException(ex);
}
return tcs.Task;
@ -189,8 +196,6 @@ namespace Emby.Common.Implementations.Net
taskSource.TrySetException(ex);
}
//_Socket.SendTo(messageData, new System.Net.IPEndPoint(IPAddress.Parse(RemoteEndPoint.IPAddress), RemoteEndPoint.Port));
return taskSource.Task;
#endif
//ThrowIfDisposed();