AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones Net
  • 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
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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 RPCConnection (Address, User, Password)
// Connection to an RPC server
ConnectionNum is int
ConnectionNum = NetConnect(Address, RPCServer, User, Password)
RETURN ConnectionNum
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.
// Initialization code of "RPCClient" window
GLOBAL
Transfer_Completed is boolean = False
Transfer_InProgress is boolean = False
 
Event("ProgBar_Transfer", "RPCClient", "SendFile")
....
ConnectFTP is int = NetConnect("148.61.125.245", FTPServer, "GUEST", "")
...
// -- Button for sending the transfer
IF Transfer_InProgress = True THEN
	Error("A file transfer is in progress")
ELSE
	Transfer_Completed = False
	Transfer_InProgress = True
	IF NetSendFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", ...
			"SendFile", 10) = False THEN
		Info("The transfer failed")
	END
	...
END
// -- ProgressBar_Tansfer procedure: managing the current transfer
PROCEDURE ProgBar_Transfer
Message("Transfer in progress")
ProgressBar(_EVE.wParam, _EVE.lParam)
IF _EVE.wParam = _EVE.lParam THEN
	Transfer_InProgress = False
	Transfer_Completed = True
	Message("Transfer completed")
	Info("Transfer completed")
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.
// -- Window opening code
// Request a message from Windows
GLOBAL
	WM_MYMESSAGE is int
	lpString is string fixed on 20 = "ProgBar_Main"
	ConnectFTP is int
// Connection
ConnectFTP = NetConnect("148.61.125.245", FTPServer, "GUEST", "")
 
WM_MYMESSAGE = CallDLL32("USER32", "RegisterWindowMessageA", &lpString)
 
// Branch the ProgBar procedure on this message
Event("UPDProgBar", "MAIN", WM_MYMESSAGE)
// -- Code of button for file retrieval
HourGlass(True)
IF NOT NetGetFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", WM_MYMESSAGE, 10) THEN
	Error("Error while transferring the file")
END
HourGlass(False)
// -- UPDProgBar() procedure
PROCEDURE UPDProgBar()
// Display the progress bar
// If the entire file is transferred, reinitialize the progress bar
IF _EVE.wParam = _EVE.lParam THEN
	// Transfer completed
	ProgressBar()
ELSE
	// Transfer in progress
	ProgressBar(_EVE.wParam, _EVE.lParam, "Transfer in progress")
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:
// Disconnection from a WINDEV RPC server
// ConnectionNum contains the value returned by NetConnect
NetDisconnect(ConnectionNum)
Versión mínima requerida
  • Versión 9
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local