
正文
vb.net服务器检测 vbnet serialport
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net socket怎么判断客户端和服务器的连接断开了? thank you!
tcp
还是
udp?
tcp
的话
try
-
catch
就行了,因为
tcp
要求的是稳定的连接,连接一断开直接就
throw
exception
了。
udp
的话,因为它本身是无连接的协议,所以其实不存在断开不断开的,准确的说应该是超时。可以客户端每隔一段时间向服务端发送个心跳包(随便什么数据都行,只是证明客户端还在线),服务端每隔一段时间检测在线的客户端列表,谁已经很久没发来心跳包了就证明它掉线了。
相关问答
Q1: 谁有vb.net测试ftp服务器上文件是否存在的代码
Dim ftpclient As System.Net.FtpWebRequest = System.Net.FtpWebRequest.Create(New System.Uri("软件"))
ftpclient.UseBinary = True
ftpclient.Credentials = New System.Net.NetworkCredential("upload", "upload")
ftpclient.Method = System.Net.WebRequestMethods.
ftpclient.KeepAlive = False
Dim ftpresponse As System.Net.FtpWebResponse = CType(ftpclient.GetResponse, System.Net.FtpWebResponse)
Console.WriteLine(ftpresponse.StatusCode.ToString + " " + ftpresponse.StatusDescription)
Dim content(1024) As Byte
Dim index_a As Integer = 0
index_a = ftpresponse.GetResponseStream.Read(content, 0, content.Length)
Dim contentstring As String = String.Empty
While index_a 0
index_a = ftpresponse.GetResponseStream.Read(content, 0, content.Length)
contentstring += System.Text.Encoding.UTF8.GetString(content)
End While
ftpresponse.Close()
If contentstring.LastIndexOf("aaa.txt") 0 Then
MsgBox("存在")
Else
MsgBox("不存在")
End If
Q2: vb.net判断服务器上是否存在文件
可以使用Get方法先获取目录的文件列表,再分析列表,检测目标文件是否存在。
关于vb.net服务器检测和vbnet serialport的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






