Network Unavailable

mafrosis

Well-known member
Joined
Jun 5, 2006
Messages
88
Location
UK
Programming Experience
5-10
Hey all,

I've been having loads of trouble with the network suddenly going down at my workplace - there are many different ways of handling this, but I just wanted to check if anyone has a good suggestion for managing exceptions on network access throughout an application?

I was thinking perhaps a single gateway class which does all network comms and handles the failure/success of any network transactions.. I'm not sure.

Many ways to skin the cat!
 
With .NET 2.0 it's extremely easy. Prior to handling any network methods you may want to check whether or not you're connected. You could use the simple:

VB.NET:
My.Computer.Network.IsAvailable

Or something that performs a ping if you require external connectivity, i.e. you may be on a LAN but not able to reach external sites, in that case, something like this may help you:

VB.NET:
Shared Function IsConnected(ByVal URL As String, ByVal TimeOut As Integer) As Boolean
Return My.Computer.Network.Ping(New System.Uri(URL), TimeOut)
End Function
 
VB Only?

This My. namespace is VisualBasic only? Its a nice solution, but id like something thats universal for C# and VB.NET really. :)

Perhaps handling a Try..Catch around all network access is the most appropriate way to go...
 
Back
Top