如何从telnet服务器向具有预定IP地址和端口的一个客户端发送信息?我尝试使用此代码,但是客户端无法收到消息
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
Dim ipserver As String = "192.168.0.11"
Dim portserver As Integer = 5432
_server = New TcpListener(IPAddress.Parse(ipserver), portserver)
_server.Start()
Threading.ThreadPool.QueueUserWorkItem(AddressOf NewClient)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub NewClient(state As Object)
Dim client As TcpClient = New TcpClient("192.168.0.3", 5432)
Try
_listofclients.Add(client)
Threading.ThreadPool.QueueUserWorkItem(AddressOf NewClient)
While True
Dim serverns As NetworkStream = client.GetStream()
serverns.Write(Encoding.ASCII.GetBytes(coba2), 0, coba2.Length)
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try
Throw New NotImplementedException()
End Sub