检查在线状态,例如通过ping [英] Check online status, for example by pinging

查看:79
本文介绍了检查在线状态,例如通过ping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.NET开发适用于Windows 10 IoT的通用Windows应用程序. 我正在检查两件事-首先是,是否有任何网络.我正在使用

I am developing an universal windows app for Windows 10 IoT using VB.NET. I am checking for two things - first is, if there is any network at all. I am using

Imports System.Net
NetworkInformation.NetworkInterface.GetIsNetworkAvailable

为此.但这并不能告诉我是否真的可以访问互联网,它仅表明我是否已连接到网络.

for this. But what this does not tell me is if I really do have internet access, it only indicates if I am connected to a network.

有什么方法可以ping地址(例如8.8.8.8)吗?我找不到解决方法. 该设备仅可用于私人目的,如果需要此信息,则该应用不会公开.

Is there any way to ping an address (like 8.8.8.8)? I cannot find a solution. The device will only be used for private purposes, the app will not be public, if that information is necessary.

推荐答案

您可以使用:
My.Computer.Network.Ping("192.168.1.1")来ping ip

My.Computer.Network.Ping("www.google.com")来ping URL

You can use:
My.Computer.Network.Ping("192.168.1.1") to ping an ip
or
My.Computer.Network.Ping("www.google.com") to ping a url

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If My.Computer.Network.Ping("192.168.1.1") Then
        MsgBox("Connection ok")
    Else
        MsgBox("No Connection")
    End If
End Sub

这篇关于检查在线状态,例如通过ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆