473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

online/offline status

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

Nov 21 '05 #1
3 3138
Well, if you can migrate to .Net v 2.0 (just released), it has a
built-in Ping class. If you're stuck using .Net v1.1, you could try this
class: http://www.codeproject.com/dotnet/CSharpPing.asp

--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"kotori" <ko******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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

Nov 21 '05 #2
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?

Nov 23 '05 #3
http://www.google.com/search?hl=en&q=ping+c%23

--

Derek Davis
dd******@gmail.com

"kotori" <ko******@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
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?

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stefan Behrens | last post by:
Hi, i try get information about the online or offline status of a database within ms-sql srv 2000. I can look it up within server manager, but I'm looking for a way to get this information...
1
by: Stefan Behrens | last post by:
Hi, i try get information about the online or offline status of a database within ms-sql srv 2000. I can look it up within server manager, but I'm looking for a way to get this information...
2
by: Daniel Orner | last post by:
Is it at all possible to use JavaScript to find out if someone's online or not? E.g. to try and fetch a URL and figure out if it failed or not? I'm trying to add some functionality to my primarily...
7
by: giddy | last post by:
hi, i'm making a netowork based app. and if i have the UNC path to a local computer is there a way i can check whether the pc is online/offline?? Gideon
10
by: Php Developer | last post by:
I want to know how to check that user is online or offline status if he close his browser with the help of <body onunload>.As it not work well if is user change his page as that time it is too...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.