我是新手,正在尝试编写一个客户端代码,该代码从服务器接收数据并输出到文本框。问题是当循环中的第二个ServerStream.Read(inStream, 0, inStream.Length)初始化inStream值时。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ServerStream.Read(inStream, 0, 5)
ReceivedData = Encoding.ASCII.GetString(inStream)
ServerStream.Flush()
If (String.Compare(ReceivedData, "_OK_") = 0) Then
msg(ReceivedData)
Do
Dim recv = ServerStream.Read(inStream, 0, inStream.Length)
ReceivedData = Encoding.GetEncoding("Windows-1252").GetString(inStream, 0, recv)
msg(ReceivedData)
If (String.Compare(ReceivedData, "END") = 0) Then
msg("Server closed")
End If
Loop While ServerStream.DataAvailable
Else
msg("Unable to recieve msg")
End If
End Sub
我正在浏览网站,但仍然不明白我做错了什么......