【发布时间】:2017-07-10 10:48:21
【问题描述】:
我正在尝试捕获通过 TCP 端口 based on this tutorial 发送的所有数据。但是,一旦收集了所有数据,语句就会随机结束
i = stream.Read(bytes, 0, bytes.Length)
一旦while 循环收集了我需要的所有数据,然后就可以使用它,而不是让它停止。也不会抛出任何错误。我该怎么做?
i = stream.Read(bytes, 0, bytes.Length)
While(i<> 0)
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
'On second loop, once all data has been gathered, the program just drops out after this line
i = stream.Read(bytes, 0, bytes.Length)
MessageBox.Show(data)
End While
【问题讨论】:
-
你试过用异常处理程序包围它吗?
-
在什么意义上“语句随机结束”?程序终止?
标签: c# vb.net sockets tcp listener