本文介绍了VB.NET客户端服务器简单应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好我开始在VB.NET中学习服务器客户端应用程序。本教程是我搜索过的 https://www.youtube.com/watch?v=MSiBbtxWpI8 [ ^ ] 但是我的 ReadLine 在打开客户端应用程序时暂停 私有 Sub 倾听() 执行直到不 IsListening 如果 Server.Pending 那么 Client = Server.AcceptTcpClient ClientData = 新 IO.StreamReader(Client.GetStream) 结束 如果 尝试 RaiseEve nt MessageReceived( Me ,ClientData.ReadLine)' PAUSE Catch ex As 异常 RaiseEvent MessageReceived( Me , 错误) 结束 尝试 Threading.Thread.Sleep( 100 ) 循环 结束 Sub 首先,我尝试过重做这与使用Timer或Backgroundworker相同。所以我复制了教程中显示但无法正常运行的代码。 请帮助..谢谢解决方案 好的是 - 它会做的。 ReadLine是所谓的阻塞操作:它直到流提供完整的数据行(由换行符终止)或它到达时才返回流的结尾。 如果ReadLine挂起,则它正在等待TCP连接的另一端发送新的行字符或序列。 首先检查另一端:如果看起来不错,请尝试逐个字符阅读,看看你是否得到任何东西...... Hello I'm starting to learn Server Client Application in VB.NET. This tutorial is what I have searched https://www.youtube.com/watch?v=MSiBbtxWpI8[^]But my ReadLine is paused when opening the client applicationPrivate Sub Listening() Do Until Not IsListening If Server.Pending Then Client = Server.AcceptTcpClient ClientData = New IO.StreamReader(Client.GetStream) End If Try RaiseEvent MessageReceived(Me, ClientData.ReadLine) 'PAUSE Catch ex As Exception RaiseEvent MessageReceived(Me, "Error") End Try Threading.Thread.Sleep(100) LoopEnd SubFirst, I have tried reworking this using Timer or Backgroundworker same happens. So I copy the code shown on tutorial but unable to run properly.Please Help.. Thanks 解决方案 Well yes - it will do.ReadLine is what is called a "blocking" operation: it does not return until the stream provides a complete line of data (terminated by a newline) or it reaches the end of the stream.If ReadLine hangs, then it is waiting for the other end of the TCP connection to send a new line character or sequence.Check the other end first: if that looks OK, try reading character by character and see if you get anything at all... 这篇关于VB.NET客户端服务器简单应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 07:41