online/offline status

  • Thread starter Thread starter kotori
  • Start date Start date
K

kotori

I'm trying to develop a program in C# that will change 'label1' in my
form to "online" if a server is present on 127.0.0.1:8080 and "offline"
if it is not.

I was playing around with this:
public static bool UrlIsValid(string smtpHost)
{
bool br = false;
try
{
IPHostEntry ipHost = Dns.Resolve(smtpHost);
br = true;
}
catch (SocketException se)
{
MessageBox.Show (se.Message);
br = false;
}
return br;
}

but that only resolves the hostname.. hence it always returns "offline"
does anyone have a better way of doing this? if there was a 'ping'
command that would probably solve this, but i would need some way to
test the ping return, see where i'm going, this has me quite confused.
Any Help would be appreciated.

~ Kotori
 
i don't think i'm limited to .net 1.1 as i've recently installed 2.0 as
of a couple weeks ago. how would i work what i'm trying to do with the
ping cmd from 2.0?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top