我必须使用vb 2010的网络程序。我正在尝试在标签文本中显示ReadLine流,但它不会显示。请帮忙。
Dim tcpCli As TcpClient = tcpList.AcceptTcpClient() 'claiming tcp listener to accept the tcp client
Dim ns As NetworkStream = tcpCli.GetStream ' assign ns as network stream and assign as client to get nw stream
Dim sr As New StreamReader(ns)
''''''''' get data from client '''''''''''''''
Dim list As New List(Of String)
Dim receivedData As String = sr.ReadLine()
MsgBox("Operation Performed!!!", MsgBoxStyle.Information, "Accepted by client")
Form1.lblRreadStream.Text = receivedData.ToString() '<< this is the line i'm stuck in with.
答案 0 :(得分:0)
根据您的要求,您可以执行以下操作之一:
Dim receivedData As String = sr.ReadLine()
While (sr.ReadLine() <> Nothing)
receivedData += sr.ReadLine()
End While
Form1.lblRreadStream.Text = receivedData
或者您可以立即阅读整个视频流:
Form1.lblRreadStream.Text = sr.ReadToEnd()
希望有所帮助