Private _clientTCPList As ArrayList = ArrayList.Synchronized(New ArrayList())
' get tcp client
Dim clientTCP As TcpClient = serverTCP.EndAcceptTcpClient(ar)
' get new ip address from tcp client
Dim newClientIPAddress as IPAddress = TryCast(clientTCP.Client.RemoteEndPoint, IPEndPoint).Address
' find new ip-address in tcp-client array list, if ip-address isn't found then add new
tcp-client to last index of aray list, but if founded then replace old tcp-client in array list with new tcp-client object.
Dim i As Integer = 0
Dim clientIPAddressFound As Boolean = False
SyncLock _clientTCPList
For Each t As TcpClient In _clientTCPList
If t.Client IsNot Nothing Then
Dim oldClientIPAddress As IPAddress = TryCast(t.Client.RemoteEndPoint, IPEndPoint).Address
If oldClientIPAddress IsNot Nothing Then
If Object.Equals(oldClientIPAddress, newClientIPAddress) Then
clientIPAddressFound = True
Exit For
End If
End If
End If
i += 1
Next
End SyncLock
'Если к серверу подключено более 1000 клиентов, выполнение цикла поиска объектов (ip-адреса) в списке массивов (tcp-клиентов) занимает много времени. Есть ли быстрый способ заменить ручной поиск работы. Спасибо