[SOLVED] LNet and FTP lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Swirl · 2018-02-06 10:43 Hi Folks still got problems to get my file transfer with LNET (0.6.5) and FTP running. (sorry Almindor...) I tried to follow Almindors/your advice but I did not succeed: QuoteClient FTP is more or less like this: FTP.Connect; // say we specified the ip and port in either OnError or OnConnect gets called, depending on if we connected or not. If we connected, in the OnConnect, you should issue the authentication commands Either OnFailure or OnSuccess will get called based on the auth result (make sure you have the auth commands in the StatusSet property, otherwise it won't be reported) As for sending, you should use OnCanSend as I wrote above in my previous post. Hope this helps. According to my understanding I tried to "file transfer" as mentioned above using the FTP component. First Event (just clicking button to start) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  FTP.Connect('myhost.de', 21);end; Second event Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FTPConnect(aSocket: TLSocket);begin  FTP.Authenticate('user', 'password');  ftp.ChangeDirectory('ftptest');end;  Third event (never fired!) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FTPSuccess(aSocket: TLSocket; const aStatus: TLFTPStatus);begin  ftp.Binary := true;  if FTP.Put('d:\swirl\projects\ftp\apple.png') then beep;end; StatusSet: all checked TRUE... I also traced  FTPError and FTPFailure: never fired... I'd be glad if anybody could help. Regards Mike ---------------------------------------------------------------------- Swirl · 2018-02-07 10:30 Does really nobody have a clue? Mike ---------------------------------------------------------------------- rvk · 2018-02-07 11:25 Try to add an event for FTPControl: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FTPControl(aSocket: TLSocket);var  s: string;begin  if FTP.GetMessage(s) > 0 then begin    Memo1.Lines.Append(s);    Memo1.SelStart := Length(Memo1.Text);  end;end; Somehow you need to read the FTPs messages before the other events work correctly B.T.W. there is a complete FTP example program at lnet\examples\visual\ftp. ---------------------------------------------------------------------- Swirl · 2018-02-07 12:31 Thanks rvk that takes me one step further. Calling "FTPControl" now causes "FTPFailure" to fire and I can dig now in the right direction... Memo tells me:    220 FTP Server ready.    502 'CWD': command not implemented.    331 Password required for u55394254    230 User u55394254 logged in    250 CWD command successful    550 ftptest: No such file or directory    250 CWD command successful    550 ftptest: No such file or directory    200 Type set to I    *** and so on ***    550 ftptest: No such file or directory    200 Type set to I "502 'CWD': command not implemented" versus "250 CWD command successful" confuses me a little bit, and I think there is a wrong order in submitting commands. I know there is an ftp example in the component directory, but analyzing code is not my major ability. Anyway I'll have a look at it now... Regards Mike ---------------------------------------------------------------------- rvk · 2018-02-07 16:19 You are FTP.Put'ing a file on EVERY FTPSuccess. But FTPSuccess is triggered a lot more than you expect. Try this and you'll understand: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses TypInfo; procedure TForm1.FTPSuccess(aSocket: TLSocket; const aStatus: TLFTPStatus);begin  Showmessage('Success ' + GetEnumName(TypeInfo(TLFTPStatus), Ord(aStatus)));  //ftp.Binary := true;  //if FTP.Put('d:\swirl\projects\ftp\apple.png') then beep;end;  You shouldn't call FTP.Put() when you are even in fsConn state.