Answer the question
In order to leave comments, you need to log in
How to check the availability of a computer in the local network in C#?
Hello!
I am making a program to check the operation of (online) computers in LAN.
Google and modifications was able to create the following code:
private Boolean ping(String host)
{
using (var p = new Process())
{
p.StartInfo.FileName = "ping.exe";
p.StartInfo.Arguments = "-n 1 " + host;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("CP866");
p.Start();
string output = p.StandardOutput.ReadToEnd();
Boolean status = output.Contains("TTL=");
return status;
}
}
response = subprocess.call(["ping", "-c", "1", host], stdout=DNULL)
if response == 0:
print("Доступен!")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question