所以到目前为止我所拥有的是一个TCP侦听器,一旦客户端连接,它将添加他们的消息将被添加到列表视图中。到目前为止这是什么。如何输入通过TCP发送到ListView的消息?这是一个WinForms应用程序。
private static void clientHandler(object client)
{
TcpClient cClient = (TcpClient)client;
NetworkStream stream = cClient.GetStream();
byte[] clientName = new Byte[1024];
stream.Read(clientName, 0, clientName.Length);
listView1.Invoke(new Action(() =>
ListViewItem newClient = new ListViewItem();
newClient.SubItems.Add(pet.Name);
newClient.SubItems.Add(pet.Type);
newClient.SubItems.Add(pet.Age);
listView.Items.Add(lvi);
));
MessageBox.Show(Encoding.ASCII.GetString(clientName));
stream.Close();
cClient.Close();
}