Net datagram getConnection method question.

Hi, I am facing a pretty strange problem (or at least I thing it is pretty strange).
I receive and accept two connections and I add then to a QueuedConnectionReader, I saved both of those connections in a list.
As the game goes I receive a message with the following code:

		while(self.cReader.dataAvailable() == True):
			datagram = NetDatagram()
			if self.cReader.getData(datagram) == True:

Then I use datagram.getConnection() to find out which client send me the message, but the returned connection is not one of those I just added to the list.

I tried printing the list and the connection, here is the result:

They are, indeed, not the same.
Is it possible for the connection to change over time? I am using a TCP connection in this code. I already sent information by this connection before receiving the message and it all went fine.

Any help is appreciated, thanks in advance.

That hex hash is just referring to the Python wrapper, which changes every time. But the underlying C++ Connection object should be the same. You can verify this by printing out connection.this.

But the == operator should also work correctly. If you say connection1 == connection2, this should report True for two connections that refer to the same underlying C++ object, even if they have different Python wrappers. Similarly, dictionaries, lists, and sets and all of the normal Python structures should properly treat these objects as the same. Only “is” or “is not” would treat them as different, so don’t use that on Connection objects like this.


Thanks for the answer, I had two dicts as argument and was using them in the wrong order… :confused:

I feel really stupid now =(