How to determine if the current online!

xiaoxiao2021-03-06  59

The specific process is as follows:

private static string LinkPing (string strIp) {Process p = new Process (); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = True; p.startinfo.redirectStandarderror = true; p.startinfo.createnowindow = true; string pingrst; p.Start (); p.standardinput.writeline ("ping -n 1 strip); p.standardInput.writeline "exit"); string strrst = p.standardoutput.readtoend (); if (Strrst.indexof ("(0% loss))! = - 1) pingrst =" Internet connection is normal! "; Else IF (Strrst.indexof) ("Destination host unreachable.")! = - 1) pingrst = "Unable to reach the host"; ELSE IF ("Request Timed Out.")! = - 1) Pingrst = "Connection timeout, please try again Once "; Else IF (" Unknown Host ")! = - 1) pingrst =" Unable to resolve the host "; else pingrst =" [unknown error]: " strrst; p.close (); return pingrst; }

As long as the function is called, it is available for judgment.

Network address is available to have this function return text

Judging whether the current online!

转载请注明原文地址:https://www.9cbs.com/read-117991.html

New Post(0)