Home Forums Support new TCPConnection WITHOUT being reused Reply To: new TCPConnection WITHOUT being reused

#4013
Anonymous
Inactive

By the way, I currently have a working workaround in place


lock (m_SyncRoot)
{
    ConnectionInfo connInfo = new ConnectionInfo("127.0.0.1", port);
    while (NetworkComms.GetExistingConnection((EndPoint)connInfo.RemoteEndPoint, (EndPoint)connInfo.LocalEndPoint, connInfo.ConnectionType, connInfo.ApplicationLayerProtocol).Count != 0)
    {
        (connInfo.LocalEndPoint as IPEndPoint).Port = m_Rnd.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort);
    }
    m_Connection = TCPConnection.GetConnection(connInfo);

    LogInformation("Client using '{0}' endpoint", connInfo.LocalEndPoint);
}

However, this is not a “good looking” code. I would prefer to have native support.

Regards
Joao