I’m attempting to create multiple clients within the same process. Each client will try to connect to the same server on the same IP address and port.
When i use TCPConnection.GetConnection i keep on getting the same local endpoint, in fact this appears to be the same connection retrieved each time.
This appears to be entirely consistent with the documentation so no issues there really.
I assume if i were connecting to different remote endpoints, that i would get different connections each time, but i haven’t tested this.
I want to set up a test system mainly for profiling, so having 100 separate client programs isn’t really what I’m after.
Is it possible to establish, say, 100 connections to the same IP and port from within the same process?
Many thanks for your post and thank-you for your support of our network library.
You are correct that NetworkComms.Net will always use an existing connection to the same remote endpoint if one exists. This is to ensure the overhead due to connection establishment is minimised. Unless you modify the source it is not possible to prevent this behaviour.
What you can do however is create N listeners, all on a different ports (but the same IP), and then connect to each port independently. If you purchased either the Indie or Enterprise packages there is an included sample that does the above, in the DebugTest project, NumConnectionsLoadTest.cs.