From abca669f5c4eb8c3edea55ff68a2611a43e33390 Mon Sep 17 00:00:00 2001 From: JamJar00 Date: Sat, 14 May 2016 20:54:06 +0100 Subject: [PATCH] Removed some todos --- Hazel/UdpClientConnection.cs | 14 +++++++++++--- Hazel/UdpConnection.Reliable.cs | 14 +++++++------- Hazel/UdpConnection.cs | 2 +- Hazel/UdpConnectionListener.cs | 2 +- Performance1.psess | 21 +++++++++++++++++++++ 5 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 Performance1.psess diff --git a/Hazel/UdpClientConnection.cs b/Hazel/UdpClientConnection.cs index 5194cc5..dbf4820 100644 --- a/Hazel/UdpClientConnection.cs +++ b/Hazel/UdpClientConnection.cs @@ -99,11 +99,19 @@ namespace Hazel State = ConnectionState.Connecting; + //Calculate local end point + EndPoint localEndPoint; + if (nep.EndPoint is IPEndPoint) + localEndPoint = new IPEndPoint(((IPEndPoint)nep.EndPoint).Address, 0); + else if (nep.EndPoint is IPEndPoint) + localEndPoint = new DnsEndPoint(((DnsEndPoint)nep.EndPoint).Host, 0); + else + throw new ArgumentException("Can only connect using an IPEndPoint or DnsEndpoint"); + //Begin listening try { - //TODO should that really be IPAddress.Any? - socket.Bind(new IPEndPoint(IPAddress.Any, 0)); + socket.Bind(localEndPoint); } catch (SocketException e) { @@ -179,7 +187,7 @@ namespace Hazel byte[] buffer = HandleReceive(dataBuffer, bytesReceived); SendOption sendOption = (SendOption)dataBuffer[0]; - //TODO may possibly get better performance with above/below swapped and block copy added + //TODO may get better performance with Handle receive after and block copy call added //Begin receiving again try diff --git a/Hazel/UdpConnection.Reliable.cs b/Hazel/UdpConnection.Reliable.cs index d69b393..da02455 100644 --- a/Hazel/UdpConnection.Reliable.cs +++ b/Hazel/UdpConnection.Reliable.cs @@ -9,7 +9,9 @@ using System.Threading.Tasks; namespace Hazel { partial class UdpConnection - {//TODO recycle dataevents and things? + { + //TODO recycle dataevents and things? + /// /// The starting timeout, in miliseconds, at which data will be resent. /// @@ -24,11 +26,6 @@ namespace Hazel /// volatile ushort lastIDAllocated; - /// - /// The number of items to remember we have received before overwriting. - /// - private readonly int receiveCapacity = 4096; - /// /// The packets of data that have been transmitted reliably and not acknowledged. /// @@ -136,9 +133,12 @@ namespace Hazel //Handle reliableness! lock (reliableDataPacketsMissing) { + //TODO Looping of IDs + // Currently when ID loops all packets will be discarded as ID will be less than reliableReceiveLast + // And wont be in reliableDataPacketsMissing. + //If the ID <= reliableReceiveLast it might be something we're missing //HasReceivedSomething handles the edge case of reliableReceiveLast = 0 & ID = 0 - //TODO Looping of IDs if (id <= reliableReceiveLast && hasReceivedSomething) { //See if we're missing it, else this packet is a duplicate diff --git a/Hazel/UdpConnection.cs b/Hazel/UdpConnection.cs index 69628ea..4e880c0 100644 --- a/Hazel/UdpConnection.cs +++ b/Hazel/UdpConnection.cs @@ -71,7 +71,7 @@ namespace Hazel Buffer.BlockCopy(data, 0, bytes, bytes.Length - data.Length, data.Length); //Inform keepalive not to send for a while - ResetKeepAliveTimer(); //TODO keepalive tests + ResetKeepAliveTimer(); //Write to connection WriteBytesToConnection(bytes); diff --git a/Hazel/UdpConnectionListener.cs b/Hazel/UdpConnectionListener.cs index b03f160..da2c06b 100644 --- a/Hazel/UdpConnectionListener.cs +++ b/Hazel/UdpConnectionListener.cs @@ -5,7 +5,7 @@ using System.Net; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; -//TODO complete trawl through for thread safety, everywhere + /* * Copyright (C) Jamie Read - All Rights Reserved * Unauthorized copying of this file, via any medium is strictly prohibited diff --git a/Performance1.psess b/Performance1.psess new file mode 100644 index 0000000..7dc9d39 --- /dev/null +++ b/Performance1.psess @@ -0,0 +1,21 @@ + + + Sampling + None + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + + + false + + -- 2.39.5