473,800 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I check internet connection in vb

Hi all,
I am writing a program with vb.net which getting some information from
internet. I must check internet connection before some prosess.
But how?
Jul 19 '05 #1
2 25230
The WebRequest class throws a WebException when errors occur while accessing
an Internet resource, so just try to connect and trap any erro that arises.

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------

"Kadir CAMOGLU" <ka******@hotma il.com> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Hi all,
I am writing a program with vb.net which getting some information from
internet. I must check internet connection before some prosess.
But how?

Jul 19 '05 #2
dtkubal
1 New Member
just call above ftn which returns true or false


--------*********--------
Private Function IsConnectionAva ilable() As Boolean
'Call url
Dim url As New System.Uri("htt p://www.google.com/")
'Request for request
Dim req As System.Net.WebR equest
req = System.Net.WebR equest.Create(u rl)
Dim resp As System.Net.WebR esponse
Try
resp = req.GetResponse ()
resp.Close()
req = Nothing
Return True
Catch ex As Exception
req = Nothing
Return False
End Try
End Function
May 31 '06 #3

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

Similar topics

6
2590
by: Matt Hawley | last post by:
I'm facing a problem where I need to verify that my windows forms application has access to the internet before it can do anything. Currently, the only way I can think of is by creating a HttpWebRequest and point it to the specified URL I wish to connect to later on, and if that throws an error, I know I don't have an internet connection. Is this the best method for detecting an internet connection, or is there some sort of routine that I need...
0
1300
by: sleepyant | last post by:
Hi, how can I check the internet connection and pop-up a Dial-Up Networking dialog when there isn't any? I've tried the following: Dim myReq As HttpWebRequest Try myReq = WebRequest.Create("http://www.yahoo.com/") myReq.GetResponse() Catch ex As Exception
9
2307
by: sleepyant | last post by:
Hi, I've posted this question on several forum but have no response. So I hope anyone who have any idea what I'm talking about please give your solution or advice. My problem is I need to check the internet connection and pop-up a Dial-Up dialog when there isn't any? I've tried the following: Dim myReq As HttpWebRequest
8
3285
by: Jozef | last post by:
Hello, Is there a way to test that an internet connection exists and that you are able to see the webserver before performing any connections? The reason being, when I try to connect to an SQL database it takes sooo long to time out if the connection isn't available. If a user is on a dial up connection, I'd like to be able to determine that quickly, then ask the user if they would like to connect for current information otherwise rely...
3
6643
by: Jonny | last post by:
Hi, Please could you tell me how to check for an internet connection in C. I'm using Windows 2000. Many Thanks, Jonny
2
5726
by: Ron Vecchi | last post by:
I have an aplication that will consitently be comutication with a webserver remotly via Internet. What is the best way and most lightweight way to constently check the conection so my app will know immediatly when connection is lost or connection is regained? Thanks -- Ron Vecchi
1
443
by: Kadir CAMOGLU | last post by:
Hi all, I am writing a program with vb.net which getting some information from internet. I must check internet connection before some prosess. But how?
8
11682
by: Nikola Bucic | last post by:
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
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?
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10507
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...
1
10255
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,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7582
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
5473
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...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.