473,804 Members | 3,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11682
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**********@g mail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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.Sock ets

TcpClient tcpClient = new TcpClient ();
tcpClient.Conne ct ("your_server.c om", 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**********@g mail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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**********@g mail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.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**********@g mail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.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 InternetGetConn ectedState. Regarding
defining Internet connection, I'm quite satisfied with that API.
Here is dllCall for mentioned API

[DllImport("Wini net", CharSet=CharSet .Auto)]
static extern bool InternetGetConn ectedState(ref
InternetConnect ionState lpdwFlags, int dwReserved);

Jan 5 '06 #8
Nikola Bucic wrote:

[...snip...]
Goran Sliskovic, I call API InternetGetConn ectedState. 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.

InternetGetConn ectedState 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
4983
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 unfamiliar with sockets and such, I ask for your help before getting my hands dirty. Cheers, Mickel G.
0
1126
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 internet if the PC is not already connected. Is it possible to do this and if so what do I need to do. I can see that I can check if a particular site is available and if it is not I can probably assume the PC is not connected. However I would...
4
2810
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 connected or not). I'm not interested in speed detection or any other aspect of the connection, just its existence or not. The reason is to be able to intercept link clicks on a CD-based set of HTML pages and pop up a warning if there is no...
2
3118
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 InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
1
2540
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 ras is for remote internet connection. What methods to use and how to use them? I used RASDial and RasHangUp functions to connect and disconnect. Can anyone exactly show me codes? I am using C#. Thanks. dennis --
4
5946
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 site an wait for an exception but it will cost me time (till the exception will occure) By using .NET object and methods, how can i check it?
16
2638
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 where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting language. The idea, apparently, is that the PHP interpreter writes all the error messages that are...
1
2269
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 as a virtual machine
9
1787
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 check a folder of text files to get the date modified of each file. I have no problems creating the filesystem object to extract the file info and dates. Currently using a timer I know is a poor approach to this but need some insight into a better way...
0
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10329
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.