From c02230265ce16b59ce380c8e6f0aa19c2c5ab6e0 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 27 Nov 2018 04:38:41 -0600 Subject: [PATCH] More changes to UDP --- DS4Windows/DS4Control/UdpServer.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/DS4Windows/DS4Control/UdpServer.cs b/DS4Windows/DS4Control/UdpServer.cs index 8398b1f..76ad2aa 100644 --- a/DS4Windows/DS4Control/UdpServer.cs +++ b/DS4Windows/DS4Control/UdpServer.cs @@ -85,7 +85,6 @@ namespace DS4Windows for (int num = 0; num <= 19; num++) { SocketAsyncEventArgs args = new SocketAsyncEventArgs(); - args.Completed += CompletedBuffer; args.SetBuffer(new byte[100], 0, 100); argsList[num] = args; } @@ -189,7 +188,7 @@ namespace DS4Windows int temp = 0; poolLock.EnterWriteLock(); temp = listInd; - listInd = (listInd + 1) % 20; + listInd = ++listInd % 20; SocketAsyncEventArgs args = argsList[temp]; poolLock.ExitWriteLock(); @@ -198,7 +197,6 @@ namespace DS4Windows //args.SetBuffer(packetData, 0, packetData.Length); try { udpSock.SendToAsync(args); - //udpSock.BeginSendTo(packetData, 0, packetData.Length, SocketFlags.Broadcast, clientEP, null, null); } catch (Exception e) { } } @@ -656,16 +654,14 @@ namespace DS4Windows int temp = 0; poolLock.EnterWriteLock(); temp = listInd; - listInd = (listInd + 1) % 20; + listInd = ++listInd % 20; SocketAsyncEventArgs args = argsList[temp]; poolLock.ExitWriteLock(); args.RemoteEndPoint = cl; - //args.SetBuffer(outputData, 0, outputData.Length); Array.Copy(outputData, args.Buffer, outputData.Length); try { udpSock.SendToAsync(args); - //udpSock.BeginSendTo(outputData, 0, outputData.Length, SocketFlags.Broadcast, cl, null, null); } catch (SocketException ex) { } } @@ -674,11 +670,5 @@ namespace DS4Windows clientsList.Clear(); clientsList = null; } - - public void CompletedBuffer(object sender, SocketAsyncEventArgs args) - { - //args.SetBuffer(null, 0, 0); - //args.RemoteEndPoint = null; - } } }