473,322 Members | 1,755 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,322 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 11637
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Mickel Grönroos | last post by:
Hi all, I have a silly question. Is there are simple way to check if the computer is connected to the Internet? It seems this should be a pretty straight-forward thing to do, but as I am totally...
0
by: Stephen | last post by:
I am developing a VB .Net application that accesses a web service to upload information to the company. This is all working but I have now been asked to get the program to make a connection to the...
4
by: Peter Flynn | last post by:
I'm having trouble finding example code to detect the presence of an Internet connection. It doesn't seem to be a very frequently asked question, as all I need is the answer yes or no (is the user...
2
by: Flashster | last post by:
This check seems to be 'true' even when I'm not connected to the internet. My network card is disabled also. Could someone tell me what I'm doing wrong? -- Declare Function...
1
by: den 2005 | last post by:
Hi everybody, How do you monitor the connection if it is still open or close for a dial up and internet RAS connection? I used both dialup and vpn RAS. The dialup is for modem connection and vpn...
4
by: Goldwind | last post by:
Hi, From a desktop application, i want to check if an internet connection exist. Many articles use the win api "InternetGetConnectedState", but it is no sure thing. I can check it by calling a...
16
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project...
1
by: =?Utf-8?B?QiBTaW5naA==?= | last post by:
Hi Scenario 1) Host - XP Laptop with internet connection using Sky Broadband Wireless Router Netgear DG834GT 2) MS Virtual Server 2005 - I have deployed an XP MS Virtual Server 2005 to act...
9
by: TomLasky | last post by:
Hi everyone, I'm an old school vb6 user trying to transition to VB.NET. Can anyone suggest a better approach to constantly checking something without using a timer? I'm trying to constantly...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.