如何在列表框中关闭选定的TCP

时间:2017-07-01 12:20:19

标签: vb.net

  • 我只需要使用+1(users_connection(listbox1.selectedindex +1)。关闭
  • 现在可行了

我想关闭ListBox中选定的TCP连接。

我尝试了这段代码,但它无效:

Public users_connection(999)
Public active_connections As Integer

' When a new client connect to the server
'...
Dim Stream As NetworkStream = client.GetStream()

active_connections += 1
users_connection(active_connections) = stream

'Close the connection
users_connection(ListBox1.SelectedIndex).Close()   

当我尝试在ListBox中关闭所选连接时,会出现此错误:

  

System.NullReferenceException:'对象变量或未设置块变量。'

0 个答案:

没有答案