ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / HTTP functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
InternetConnected (Function)
In french: InternetConnecté
Defines whether an Internet connection is enabled on the current computer.
AndroidAndroid Widget iPhone/iPad Allows you to be notified when the status of the Internet connection changes.
Example
// Connexion Internet active ?
ResConnexion = InternetConnected()
IF ResConnexion = True THEN
	Info("Une connexion Internet est active")
ELSE
	Info("Aucune connexion Internet n'est active")
END
Syntax

Finding out whether an Internet connection is enabled Hide the details

<Result> = InternetConnected()
<Result>: Boolean
  • True if an Internet connection is enabled on the current computer,
  • False otherwise.
AndroidAndroid Widget iPhone/iPad

Asking for a notification when the status of the Internet connection changes Hide the details

<Result> = InternetConnected([<WLanguage procedure>])
<Result>: Boolean
  • True if the procedure was associated with InternetConnected,
  • False otherwise.
<WLanguage procedure>: Procedure name
WLanguage procedure ("callback") called when the Internet connection status changes.
This procedure has the following format:
PROCEDURE <Procedure name>(<Status>)
<Status> is an integer constant corresponding to the new status of the Internet connection.
It can take the following values:
networkDisconnectedThe network is disconnected or inaccessible.
networkEthernetThe Internet connection is performed by Ethernet.
networkMobileThe Internet connection is made in mobile mode: edge, 2G, 3G, 4G, etc.
networkWifiThe Internet connection is performed by Wi-Fi.

If <WLanguage procedure> is an empty string (""), the previously defined WLanguage procedure will no longer be called.
Remarks
AndroidAndroid Widget Required permissions
This function changes the permissions required by the application.
Permission required: ACCESS_NETWORK_STATE: this permission allows applications to access network information.
AndroidAndroid Widget iPhone/iPad Change of connection status (syntax 2)
  • Call to the procedure:
    • iPhone/iPad The WLanguage procedure is called only when the network status changes. It is not called when InternetConnected is called. You must call InternetConnected (without parameters) to know whether or not the Internet connection is enabled.
    • AndroidAndroid Widget The WLanguage procedure is automatically called when InternetConnected is called.
  • Only one procedure can be associated with InternetConnected. If InternetConnected is called multiple times with different procedure names, the procedure used to detect the status of the Internet connection will be replaced by the last procedure specified.
  • AndroidAndroid Widget If InternetConnected is called from a secondary thread, the procedure will be called in the main thread of the application.
Component: wd300com.dll
See also
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo
sRetorno is string = ""

cMyRequest is httpRequest

IF InternetConnected() = False THEN

ToastDisplay("Sem conexão com a internet",toastShort,vaBottom,haCenter)

RETURN("OFF")

ELSE

cMyRequest.URL = URL_SISTEMA+REGRA_PING
cMyRequest.Timeout = 45s

cMyResponse is httpResponse = HTTPSend(cMyRequest)

IF cMyResponse.StatusCode = 200 THEN

//sRetorno = AnsiToUnicode(cMyResponse.Content)
sRetorno = UTF8ToAnsi(cMyResponse.Content)

RETURN(sRetorno)

ELSE

RETURN("NOK")

END

END
Boller
23 May 2023
** Dica **
Cuidado, ao utilizar essa função, não é confiável para testar Internet. Usavamos em nosso ERP, porém aconteceu de parar nossa emissão de NFe devido a função retornar equivocadamente que não tinha Conexão de Internet na máquina.

Para testar Conexão de Internet recomendo utilizar, o Post do Adriano Boller:
http://forum.pcsoft.fr/fr-FR/pcsoft.us.windevmobile/605-conexao-internet/read.awp
Danilo
22 Dec. 2016

Last update: 03/27/2025

Send a report | Local help