471,325 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

constantly checking internet connection

Could someone tell me how can I constantly check if I'm connected to
internet and if possible to determine what type of connection is it.

My best shot wright now is to have a timer which will periodicaly call
API to check whether am I connected or not

Dec 27 '05 #1
8 11488
Hi,

And that's the best option IMO, in the handler you could check for the kind
of connectivity you want and send an event to the UI in case you need to.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Nikola Bucic" <ni**********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Could someone tell me how can I constantly check if I'm connected to
internet and if possible to determine what type of connection is it.

My best shot wright now is to have a timer which will periodicaly call
API to check whether am I connected or not

Dec 27 '05 #2
If you want to check if there is an ability to connect to specific server on
the internet you can
check internet connection, performimg basic network operation ( connection )
System.Net.Sockets

TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("your_server.com", 80);
//Connection is present
tcpClient.Close();

Generally connection means that there will be server and client. As I
understood you're in the client's role?
if so it is only necessary to check the accessability of the server in order
to determine if connection is present.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Nikola Bucic" <ni**********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Could someone tell me how can I constantly check if I'm connected to
internet and if possible to determine what type of connection is it.

My best shot wright now is to have a timer which will periodicaly call
API to check whether am I connected or not

Dec 27 '05 #3
it's not important whether I'm on server or on client side. I just want
to have constantly monitoring over internet connection and when my PC
become online run some code

Dec 28 '05 #4
You mean hardware connection? Smth like when ethernet cable is plugged or
unplugged?

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Nikola Bucic" <ni**********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
it's not important whether I'm on server or on client side. I just want
to have constantly monitoring over internet connection and when my PC
become online run some code

Dec 28 '05 #5
You can develop an windows Service which will fire an API to check whether
ur PC is conencted to Internet or not
and You can get its status using Notify Icon.
--
Best Regards
Rahul Goel
Dec 28 '05 #6

"Nikola Bucic" <ni**********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
it's not important whether I'm on server or on client side. I just want
to have constantly monitoring over internet connection and when my PC
become online run some code


"Internet connection" is very hard to define. You can be connected over LAN,
through ethernet. You may have dial-up connection, wireless, DSL or
something else. Even if your ethernet interface is up, that does not mean
that you can connect to internet. There may be firewalls that restrict
access (totally or to some services). IMHO, if you need to connect to some
server to do some work, don't check for internet connection, check for
servers availability. Try to connect and if it works, it works :)

Regards,
Goran

Dec 28 '05 #7
Rahul, I want it to be a Service, but can you tell me do I need timer
to check Connection state or is there some windows message(s) that I
can trap?

Goran Sliskovic, I call API InternetGetConnectedState. Regarding
defining Internet connection, I'm quite satisfied with that API.
Here is dllCall for mentioned API

[DllImport("Wininet", CharSet=CharSet.Auto)]
static extern bool InternetGetConnectedState(ref
InternetConnectionState lpdwFlags, int dwReserved);

Jan 5 '06 #8
Nikola Bucic wrote:

[...snip...]
Goran Sliskovic, I call API InternetGetConnectedState. Regarding
defining Internet connection, I'm quite satisfied with that API.
Here is dllCall for mentioned API

[...snip...]

Actually, it's impossible to correctly identify if a computer is connected
to "the internet" or not.

InternetGetConnectedState just reads the settings of the default connection
of IE returning "true" whenever the connection is to be established via a
LAN. If you are using Dial-Up-Connections it does not take into account how
autodial is set up (at least not correctly). Finally, it needs a complete
installation and configuration of at least IE 4 to work at all.
Jan 5 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Mickel Grönroos | last post: by
reply views Thread by Stephen | last post: by
4 posts views Thread by Peter Flynn | last post: by
2 posts views Thread by Flashster | last post: by
4 posts views Thread by Goldwind | last post: by
1 post views Thread by =?Utf-8?B?QiBTaW5naA==?= | last post: by
reply views Thread by rosydwin | last post: by

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.