Namespace:
Rebex.Net.ConnectionManagement
Assembly:
Rebex.Networking (in Rebex.Networking.dll)
Syntax
Visual Basic |
---|
Public Shared Function TryConnect ( _ timeout As TimeSpan _ ) As Boolean |
C# |
---|
public static bool TryConnect( TimeSpan timeout ) |
Parameters
- timeout
- Type: System..::..TimeSpan
Maximum allowed time for the establishment of the Internet connection
Return Value
true if the device is connected to the Internet, otherwise returns false.Remarks
Method is synchronous.
Don't rely on this method in your application code. Different devices have different capabilities and an application code that initiates reliable network connection may require use of the vendor SDK. Even if this method returns true, it is possible that a subsequent HttpRequest or any other network request may fail.
All what the method does is following. The method tries to open a connection corresponding to the predefined network path that can be identified by the well-known value IID_DestNetInternet (436EF144-B4FB-4863-A041-8F905A62C572). Usually, if the device is not connected to the Wi-Fi network or LAN, calling this method initiates connection to the mobile network (GPRS, EDGE, LTE and so on).