How to detect lost internet connection ?
-
my VB.net application uploads local files to server. Every second my application need to detect whether my application still connected to that server or lost connection, how i can detect the connection lost or still connected ? using shell or ping ? how to use it ?
Regards, Chee ken
-
my VB.net application uploads local files to server. Every second my application need to detect whether my application still connected to that server or lost connection, how i can detect the connection lost or still connected ? using shell or ping ? how to use it ?
Regards, Chee ken
hi Try this http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=215689&SiteID=1[^] Hope it Helps
Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za
-
my VB.net application uploads local files to server. Every second my application need to detect whether my application still connected to that server or lost connection, how i can detect the connection lost or still connected ? using shell or ping ? how to use it ?
Regards, Chee ken
firstly I would not check the connection every second, I would only check it just before I upload the file. I use a function like the following to check if a connection exists :-
Public Shared Function IsWebSiteAvailable(ByVal Address As String) As Boolean Try Dim oUrl As New System.Uri(Address) Dim oWebRequest As System.Net.WebRequest = System.Net.WebRequest.Create(oUrl) Dim oResponse As System.Net.WebResponse = oWebRequest.GetResponse oResponse.Close() oWebRequest = Nothing Return True Catch Return False End Try End Function
There I would the code the upload as followsIf IsWebSiteAvailable("www.mysite.com") Then DoUpload() Else MessageBox.Show("Internet connection unavailable.") End If
Steve Jowett ------------------------- Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'