Bandwidth Leak? Please check.

Michaelk

Well-known member
Joined
Jun 3, 2004
Messages
58
Location
Australia
Programming Experience
3-5
Hi, I wrote an Internet connection status program to run on my server, and alert me when the internet became disconnected. It was probably just a coincidence, but the month that I tested it, I went way over my internet bandwidth cap. Can someone please just have a quick look over this code and tell me if there is a bandwidth leak?

When it runs it uses about 0.3% of the network, for less then a second. So I don’t see how it could be using the bandwidth. I probably just downloaded too much that month, but none the less. Is anything wrong with this?

VB.NET:
 [size=2]
 
[/size][size=2][color=#0000ff]Try[/color][/size]
[size=2][color=#008000]'Check Web Connection[/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] WebRequest [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Net.WebRequest[/size]
[size=2][color=#008000]' Initialize the WebRequest.
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] myRequest [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Net.WebRequest = WebRequest.Create([url="http://www.microsoft.com/"]http://www.microsoft.com[/url])[/size]
[size=2][color=#008000]' Return the response. [/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] myResponse [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Net.WebResponse = myRequest.GetResponse()[/size]
[size=2][color=#008000]' Code to use the WebResponse goes here.[/color][/size]
[size=2][color=#008000]' Close the response to free resources.[/color][/size]
[size=2]myResponse.Close()
[/size][size=2][color=#0000ff]Catch[/color][/size][size=2] ex [/size][size=2][color=#0000ff]As[/color][/size][size=2] Exception[/size]
[size=2][color=#008000]' The Web request failed. Use code here.[/color][/size]
[size=2][color=#008000][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Try
[/color][/size][/color][/size]
I got the code out of the MSDN library, i put my own code for a failed connection, and the WebResponse code.
It attemtps a connection every 10 minutes, and uses a progress bar for the timer.
Thanks for your time,
 
Back
Top