internal void HandleUnicastTCPConnectionToRemoteProxy(string HostName, int listeningTCPPortNumber) { //creates a unique string ID using the hostname and the port number in order to determine it there //is a previous connection to that port string connectionPortStringID = ""; connectionPortStringID = this.GetConnectionStringID(HostName, listeningTCPPortNumber); if (!this._TCPSocketsConnectionStringIDReferenceTable.Contains(connectionPortStringID)) { SocketsServerClient socketsServerClient = new SocketsServerClient(HostName, listeningTCPPortNumber); socketsServerClient.Connect(); socketsServerClient.ConnectionLost += TCPSocketsServerClient_ConnectionLost; //----------------------------------------------------------------- //adds to the socketsServerClients Table that hold the connection handlers lock (this._TCPSocketsServerClientsTable) { try { this._TCPSocketsServerClientsTable.Remove(socketsServerClient.ClientID); } catch (Exception) { } this._TCPSocketsServerClientsTable.Add(socketsServerClient.ClientID, socketsServerClient); } //----------------------------------------------------------------- //adds to the reference connectionsStringID in order to know that a connection to the //specified host and port exists already lock (this._TCPSocketsConnectionStringIDReferenceTable) { try { this._TCPSocketsConnectionStringIDReferenceTable.Remove(connectionPortStringID); } catch (Exception) { } this._TCPSocketsConnectionStringIDReferenceTable.Add(connectionPortStringID, socketsServerClient); } } }