ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Net functions
  • Implementation
  • Details of different steps
  • Step 1: Establishing a connection with a WINDEV RPC or FTP server
  • Step 2: Transmitting a file to a WINDEV FTP server
  • Step 3: Retrieving a file from a WINDEV FTP server
  • Step 4: Closing a connection with a WINDEV RPC or FTP server
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Implementation
To upload and download files, you must comply with the following rules:
  1. Connect to a WINDEV FTP server with NetConnect. This function establishes a connection between WINDEV and the server and it provides a connection identifier.
  2. Upload, download files.
  3. Close the connection to the server with NetDisconnect.
Remarks:
  • The TCP/IP communication protocol must be installed and an IP address must be defined.
  • To create a WINDEV FTP/RPC server, all you have to do is use NetStartServer.
Details of different steps

Step 1: Establishing a connection with a WINDEV RPC or FTP server

To transfer files, a connection must be established to a WINDEV RPC or FTP server. The connection is established by NetConnect. The code for establishing a connection must be found before the first "Net" function. The value returned by NetConnect must be stored because this one will be used by the other "RPC" and "FTP" functions.
The code used to connect to an RPC server is as follows:
FUNCTION ConnexionRPC(Adresse, Utilisateur, Motdepasse)
// Connexion à un serveur RPC
NumConnexion is int
NumConnexion = NetConnect(Adresse, RPCServer, Utilisateur, Motdepasse)
RETURN NumConnexion
Remark: How to create a WINDEV RPC or FTP server?
To create a WINDEV RPC or FTP server, you must create an application that uses NetStartServer to start the server. NetEndServer is used to stop this server.
The WDRPCSRV.INI file that contains the connection rights granted to the users. This text file and the WINDEV RPC/FTP server are found in the same directory. It must contain a "password" section in which each entry point is a username:
[Passwords]
UserName1=Password1
UserName2=Password2
UserName3=Password3
...
Remarks:
  • The server must be accessible by all the client computers (by TCP/IP).
  • To be accessible, the server must be started.

Step 2: Transmitting a file to a WINDEV FTP server

In the following example, a file is transmitted to the WINDEV FTP server (NetSendFile). A progress bar is used to track the progress of the transfer.
// Code d'initialisation de la fenêtre "ClientRPC"
GLOBAL
Transfert_Terminé is boolean = False
Transfert_EnCours is boolean = False
 
Event("Jauge_Transfert", "ClientRPC", "EnvoieFichier")
....
ConnectFTP is int = NetConnect("148.61.125.245", FTPServer, "GUEST", "")
...
// -- Bouton d'envoi du transfert
IF Transfert_EnCours = True THEN
	Error("Un transfert de fichier est actuellement en cours")
ELSE
	Transfert_Terminé = False
	Transfert_EnCours = True
	IF NetSendFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", ...
			"EnvoieFichier", 10) = False THEN
		Info("Échec du transfert")
	END
	...
END
// -- Procédure Jauge_Transfert : gestion du transfert en cours
PROCEDURE Jauge_Transfert
Message("Transfert en cours")
ProgressBar(_EVE.wParam, _EVE.lParam)
IF _EVE.wParam = _EVE.lParam THEN
	Transfer_EnCours = False
	Transfert_Terminé = True
	Message("Transfert terminé")
	Info("Transfert terminé")
END

Step 3: Retrieving a file from a WINDEV FTP server

NetGetFile is used to retrieve a file found on the WINDEV FTP/RPC server.
Remark: it is possible to easily find out the list of directories and files on a WINDEV FTP server.. An example is available in the description of NetDirList.
// -- Code d'ouverture de la fenêtre
// Demande d'un message disponible à Windows
GLOBAL
	WM_MYMESSAGE is int
	lpString is string fixed on 20 = "Jauge_Main"
	ConnectFTP is int
// Connexion
ConnectFTP = NetConnect("148.61.125.245", FTPServer, "GUEST", "")
 
WM_MYMESSAGE = CallDLL32("USER32", "RegisterWindowMessageA", &lpString)
 
// Branchement de la procédure Jauge sur ce message
Event("MAJJauge", "MAIN", WM_MYMESSAGE)
// -- Code du bouton de récupération de fichier
HourGlass(True)
IF NOT NetGetFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", WM_MYMESSAGE, 10) THEN
	Error("Erreur dans le transfert de fichier")
END
HourGlass(False)
// -- Procédure MAJJauge()
PROCEDURE MAJJauge()
// Affichage de la jauge
// Si tout le fichier est transféré, on réinitialise la jauge
IF _EVE.wParam = _EVE.lParam THEN
	// Transfert terminé
	ProgressBar()
ELSE
	// Transfert en cours
	ProgressBar(_EVE.wParam, _EVE.lParam, "Transfert en cours")
END

Step 4: Closing a connection with a WINDEV RPC or FTP server

Once the files have been transferred, you must disconnect from the WINDEV RPC or FTP server. The disconnection is performed by NetDisconnect. The disconnection code must be found after the last "Net" statement. The "ConnectionNum" variable, required for the disconnection, contains the value returned by NetConnect. The code used to disconnect from a WINDEV RPC server is as follows:
// Déconnexion à un serveur RPC WinDev
// NumConnexion contient la valeur retournée par NetConnecte
NetDisconnect(NumConnexion)
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help