access violation while using Lnet TCP Server Console lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- opendelphi · 2019-04-18 11:43 Hi guys , i am trying to extend the lnet tcp server console sample by allowing receiving files from tcp server . the error msg while try to download the file from server 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 An unhandled exception occurred at $0000000000428D7F:                                                   EAccessViolation: Access violation       $0000000000428D7F                            $000000000047840F line 1086 of ../lib/lnet.pp                                                                         $0000000000400EC5 line 167 of lserver.pp  so this is server side code on receive 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    if aSocket.GetMessage(FServerReceivedStr) > 0 then begin    if FServerReceivedStr <> 'file' then     writeln(FServerReceivedStr)     else        begin          FIStream.LoadFromFile('/root/Desktop/enumeration/server/file.txt');        n := FIStream.Size;          SetLength(FBuffer, FIStream.Size);          n := Length(FBuffer);          FIStream.Position := 0;        FIStream.Read(FBuffer[0], FIStream.Size);          n := Length(FBuffer);          FPos := 0;    // send image          OnCa(aSocket);        end;     // if send fails write error   // end; end;end;                         on Can Send : 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  if FServerReceivedStr = 'file' then  begin  { repeat the sending until we sent the whole buffer, or .Send return 0 -- means we filled the send buffer for now. NOTE: FSendIndex  has to begin at 1 for a string! }  repeat    { try to send the rest of the buffer we didn't send yet }    n := Length(FBuffer) - FPos;      if n > 0 then        n := FCon.Send(FBuffer[FPos], n);    { if we sent something, move us in the buffer so we don't re-send the same part }      Inc(FPos, n);    until (n = 0) or (FPos > Length(FBuffer));  end  else    FCon.SendMessage(FServerReceivedStr, aSocket); ---------------------------------------------------------------------- lucamar · 2019-04-18 14:14 I have a limited knowledge of lnet but there doesn't seem to be anything very wrong in those snippets, other than the total lack of exception handling in both, and the multiple times you set n (without using it for anything) to the same value in one form or another in the first. Can you share a compilable demo or more detailed code (p.e. to see where and how you're creating the streams, what OnCa() does etc.)? And what's there in the lines pointed to by the exception message? ---------------------------------------------------------------------- opendelphi · 2019-04-18 15:20 i have fixed that error but still not able to get the file from server into client , below is example of code .