lnobad / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

IPEndPoint more optimal for lookups #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have an application which needs to hold onto the connection seperatly.  The 
NetConnection is too large for a lookup but have been using the IPEndPoint and 
using GetConnection(IPEndPoint) in the sender.  IPEndPoint is more lean and 
less memory usage in the lookup list.  Would it be a good idea to expose 
GetConnection in NetPeer as public and not internal.  This i found very 
practical for me.

Original issue reported on code.google.com by mark.js...@googlemail.com on 23 Nov 2010 at 7:07

GoogleCodeExporter commented 9 years ago
I don't understand the issue. A reference in a lookup (say, a Dictionary<>) is 
equally sized no matter what the size of the class referenced.

Nevertheless, a GetConnection(IPEndPoint) could be useful for applications - 
I've made it public in rev 155.

Original comment by lidg...@gmail.com on 23 Nov 2010 at 9:56

GoogleCodeExporter commented 9 years ago
Thanks

What i was referring to is that applications might want to relate their own 
data properties against a connection.  In that situation, the application will 
have to hold on to a reference to the connection, such that the connection can 
be obtained for send purposes.  The netconnection is rather large in comparison 
with the object IPEndPoint which would result in holding a duplicate set of 
NetConnections in memory.

Original comment by mark.js...@googlemail.com on 23 Nov 2010 at 10:05

GoogleCodeExporter commented 9 years ago
Since NetConnection is a class; holding a reference to it will not create any 
duplicate data, the only extra memory will be the size of the pointer.
IPEndPoint on the other hand is a struct, ie. value type, so you cannot hold a 
reference to it - only a copy.

Original comment by lidg...@gmail.com on 23 Nov 2010 at 10:15