[SOLVED] Problem with Lnet lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- magleft · 2023-08-02 11:17 Hi to all. I am using lnet to transfer a database file through ftp. The connection is made normally and the transfer to the server is made normally. When i try to transfer from server to client the file is not transferred and  the process is aborted. Displayed the message <>. Does anyone know what is wrong? ---------------------------------------------------------------------- Thaddy · 2023-08-02 14:00 Without code impossible to solve: it just means the format is not correct and can not be parsed. ---------------------------------------------------------------------- magleft · 2023-08-02 14:41 I try it with visual ftp example of lnet. The. Ftp server is on my phone (wifi ftp server app). ---------------------------------------------------------------------- magleft · 2023-08-03 11:59 Is there a possibility that the error is due to the contents of the database? The database contains Greek characters. ---------------------------------------------------------------------- KodeZwerg · 2023-08-03 12:09 What Thhady tried to say is, as long we not know how you do, all is just a wild guessing, so show us the relevant parts about the ftp connection. ---------------------------------------------------------------------- Handoko · 2023-08-03 12:20 I don't know what causes your issue. But I have bad experience with LNet. I wanted to write myself a FTP program to send and download files between my computer and a web server. I found LNet and like the name suggests 'lightweight'. After gathering some information, I managed to understand how to use LNet FTP to send/receive files. I spent quite some time to finalize that program. But I later realized, my effort wasted. I have already make sure there were no bugs in my code. But if the test files were small, some KBs only, it worked perfectly okay. But on larger files, something like 30 MB, the transfer processes succeed without error but the file size (not always but) frequently being truncated. I thought maybe there was any secret 'ingredient' I haven't known to make it work. Or maybe there was some issues with the web server. I didn't want to give up, so I downloaded and tried Ararat Synapse Indy.  To my surprise, it simply worked on my first try. You can Indy or Synapse: https://www.indyproject.org/ https://wiki.freepascal.org/Synapse ---------------------------------------------------------------------- MarkMLl · 2023-08-03 12:32 Quote from: Handoko on August 03, 2023, 02:20:52 pmI don't know what causes your issue. But I have bad experience with LNet. I didn't want to be the first person to say that. I've used it in the past because it was one of the few libraries with half-decent Telnet support, but eventually found it had real problems when a session was torn down and reconnection attempted. My attempts to debug the problem were unsuccessful, LNet has a complex internal structure which I suspect is due to its originally having been written to avoid threads. I've since written my own Telnet code, which- dare I say it- is better in every way; more significantly I delved into half a dozen legacy projects and ripped out every vestige of LNet. MarkMLl ---------------------------------------------------------------------- magleft · 2023-08-03 13:09 I would like to thank you all for your advice. I had tried synapse with no success, but will try again. About lnet I tweaked the FTPReceive event a bit and surprisingly it worked. I am attaching the modified code. 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 TFupdateDatabases.FTPReceive(aSocket: TLSocket);var  s: string;  i: Integer;  Buf: array[0..65535] of Byte;begin  if FTP.CurrentStatus = fsRetr then begin // getting file, save to file    i := FTP.GetData(Buf, SizeOf(Buf));    Inc(FDLDone, i);    if i > 0 then  begin      if Length(CreateFilePath) > 0 then      begin        FFile := TFileStream.Create(CreateFilePath, fmCreate or fmOpenWrite);      CreateFilePath := '';      end;      FFile.Write(Buf, i);      if FDLDone + i >= FDLSize then    begin // done whole file      // file download ended       sleep(500);    end    end    else if not FTP.DataConnection.Connected then begin      // file download ended    FreeAndNil(FFile);      CreateFilePath := '';      showmessage('Downloand complete');      end;    ProgressBar1.Position := Round(FDLDone / FDLSize * 100);  end  else begin // getting listing    s := FTP.GetDataMessage;    if Length(s) > 0 then      FDirListing := FDirListing + s      else begin      FList.Text := FDirListing;      FDirListing := '';      FList.Clear;    end;  end;end; ---------------------------------------------------------------------- MarkMLl · 2023-08-03 13:18 That really needs to go to LNet's Github page, since it's an external project. A version of LNet is bundled with FPC as a tool (I believe that at one time it was used in some way during installation) and it was that that I originally put some Telnet modifications into, but I believe the one on Github is from the original author and the two have diverged (that's a polite way of saying that I don't know which will be more reliable and maintainable). Having said that, if using a standard protocol I'd suggest sticking with Synapse etc., since that's where the TLC relating to SSL etc. will be going. Or if you need very low-level stuff, stick with the standard sockets API. MarkMLl ---------------------------------------------------------------------- magleft · 2023-08-03 18:08 Thanks. I will try with synapse.