ftp via Lnet example lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- mirce.vladimirov · 2015-09-27 23:22 First I placed the Lnet's ftp-component on my form so an object was created Code: [Select]FTP: TLFTPClientComponent;after that i coded this, according to examples found : Code: [Select]  ftp.Host:='myhost.com';   ftp.Port:=word(21);   ftp.Connect ; //  ftp.Connect('myhost.com',21);   ftp.Authenticate('myusername','mypwd') ;   ftp.ChangeDirectory('public_ftp');   ftp.Put('mypic.jpg');   ftp.Disconnect(true);And the file was not sent. It is sending all right if I use the synapse or the command-prompt ftp client. Obviously I'm missing something but I cant see what is it. ---------------------------------------------------------------------- derek.john.evans · 2015-09-28 01:15 The example IFTPClient has this line: Code: [Select]FCon.CallAction; // this needs to be called ASAP, in a loop. It's the magic function which makes all the events work :) EDIT: Personally, I prefer Indy because it comes with a stack of FTP list parsers. This list is from the unit IdAllFTPListParsers. Code: [Select]  IdFTPListParseAS400,   IdFTPListParseBullGCOS7,   IdFTPListParseBullGCOS8,   IdFTPListParseChameleonNewt,   IdFTPListParseCiscoIOS,   IdFTPListParseDistinctTCPIP,   IdFTPListParseEPLF,   IdFTPListParseHellSoft,   IdFTPListParseIEFTPGateway,   IdFTPListParseKA9Q,   IdFTPListParseMicrowareOS9,   IdFTPListParseMPEiX,   IdFTPListParseMusic,   IdFTPListParseMVS,   IdFTPListParseNCSAForDOS,   IdFTPListParseNCSAForMACOS,   IdFTPListParseNovellNetware,   IdFTPListParseNovellNetwarePSU,   IdFTPListParseOS2,   IdFTPListParsePCNFSD,   IdFTPListParsePCTCP,   IdFTPListParseStercomOS390Exp,   IdFTPListParseStercomUnixEnt,   IdFTPListParseStratusVOS,   IdFTPListParseSuperTCP,   IdFTPListParseTandemGuardian,   IdFTPListParseTOPS20,   IdFTPListParseTSXPlus,   IdFTPListParseUnisysClearPath,   IdFTPListParseUnix,   IdFTPListParseVM,   IdFTPListParseVMS,   IdFTPListParseVSE,   IdFTPListParseVxWorks,   IdFTPListParseWfFTP,   IdFTPListParseWindowsNT,   IdFTPListParseWinQVTNET,   IdFTPListParseXecomMicroRTOS; ---------------------------------------------------------------------- Jurassic Pork · 2015-09-28 02:04 hello, Geepster Callaction is only available in non-visual lNet QuoteThe CallAction method of all “Connections” is a method which “eventizes” the whole connection. It is valid only in non-visual lNet. Whenever you call this method, all sockets of given connection are checked for status updates (eg. if something can be received, if I can send…) and appropriate callbacks are fired. You need to call this method periodicly to assure functionality. You need to CallAction periodicly if you want to know if you can receive. (get) and mirce seems to be in a gui app : QuoteFirst I placed the Lnet's ftp-component on my form so an object was created for me (Lazarus 1.4 Windows 7) lnet FTPclient works with the ftpclient gui example but not with a project with simple mirce's code. No event , No exception : strange thing. ---------------------------------------------------------------------- Jurassic Pork · 2015-09-28 03:31 mirce, it seems that some procedures of the visual component TLFTPClientComponent are non-blocking (ie Connect ) , then you must check status of the connexion between the procedure or event drive ( see example) .  You cant' call procedure without delay between them. ---------------------------------------------------------------------- mirce.vladimirov · 2015-09-28 13:21 All right, got the point, thank you folks. Now I can upload, hooray. Still, cant get the clue about downloading, do I have to use FileStream ?  And if so, What is ftp.retrieve(s:string) in the example ? Do I have to invoke ftp.retrieve(string) and then onrecieve store it to a FileStream ? ---------------------------------------------------------------------- mirce.vladimirov · 2015-09-28 14:03 QuoteStill, cant get the clue about downloading, do I have to use FileStream ?The answer is yes, that is the way that the downloaded data is saved. QuoteDo I have to invoke ftp.retrieve(string) and then onrecieve store it to a FileStream ? And once again the answer is yes, invoke  ftp.retrieve(string) and do coding to save it in the "onrecieve" procedure. Thank to everybody. EDIT: here's the simple and short version : Code: [Select]procedure TfLnet.button1Click(Sender: TObject); begin   ftp.ChangeDirectory('/public_ftp');   ftp.Retrieve('slika1.jpg') ; end; and then: Code: [Select]procedure TfLnet.FTPReceive(aSocket: TLSocket); var FFile: TFileStream; s: string; i: Integer; newone:Boolean; Buf: array[0..65535] of Byte; begin   newone:=true; //  memo1.lines.Add('primiv bla blabla :' + FTP.GetDataMessage);   if FTP.CurrentStatus = fsRetr then begin // getting file, save to file      i := FTP.GetData(Buf, 65535);      if i > 0 then begin        if newone=true then begin  // pri prviot takt da stvori nov fajl          FFile := TFileStream.Create(GetCurrentDir+'\'+'sl1.jpg', fmCreate or fmOpenWrite);          newone:=false;        end;        FFile.Write(Buf, i);      end ;      FreeAndNil(FFile);   end; end; Once again, thanks everybody.