Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:40:42+00:00 2026-06-13T22:40:42+00:00

I have this delphi code that basically download files from a secure server (using

  • 0

I have this delphi code that basically download files from a secure server (using Indy build 10.5.8 r4743 if I’m not mistaken):

The problem is: I’m getting random “Socket Error # 0” exceptions that I couldn’t get fix or even understand:

Project MyProject.exe raised exception class EIdSocketError with message 'Socket Error # 0

Stack is here, pascal code is:

IdHTTP            := TIdHTTP.Create(nil);
TheSSL            := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
TheCompressor     := TIdCompressorZLib.Create(nil);
TheCookieManager  := TIdCookieManager.Create(IdHTTP);

try SetupWebComponents(IdHTTP, TheSSL, TheCompressor, TheCookieManager); except end;

TheCookieManager.OnNewCookie := MainForm.SyncNewCookie;

// Go!
Stream            := TMemoryStream.Create;
try
   IsError        := False;
   try
      with IdHTTP do
      begin
           OnWork                := MainForm.IdHTTPWork_Download;
           try
              try
                 IsNewFile       := (Not FileExists(LocalFile));
                 if IsNewFile then
                    TheFile      := TFileStream.Create(LocalFile, fmCreate)
                 else
                     // File already exist, resume download
                     TheFile     := TFileStream.Create(LocalFile, fmOpenReadWrite);

                 DoExit          := False;

                 // Use [ Request.Referer ] it to pass VersionGUID to Work event (to record download progress in db)
                 Request.Referer := VersionGUID;
                 repeat
                       // Get resume byte
                       if IsNewFile then
                       begin
                            ResumeByte := 0;
                            IsNewFile  := False;
                       end
                       else
                           ResumeByte  := GetResumeByteFromDB();

                       if FileExists(LocalFile) then
                       begin
                            // File already exist, resume download
                            DoExit     := (ResumeByte >= TheFileSize);
                            TheFile.Seek(ResumeByte, soFromBeginning);
                       end;

                       // Save ResumeByte, it will be used to record download progress in db & eventually use it to resume downloads)
                       IdHTTP.Tag      := ResumeByte;

                       Request.Range := IntToStr(ResumeByte) + '-';

                       Get(TheURL, TheFile);
                       IsError         := (Not (ResponseCode in [200, 206])) OR (Pos('login', URL.Document) <> 0);

                       // Break if there's any error (to allow retrying later in a clean fashion)
                       if IsError then
                          Break;
                 until DoExit;

                 Disconnect;
              except
                    if (ResponseCode = 404) then
                    begin
                         // File doesn't exist, get out
                         Result        := False;
                         Exit;
                    end;
              end;    // try/except
           finally
                  FreeAndNil(TheFile);
           end;    // try/finally
      end;    // with
   except
         IsError  := True;
   end;    // try/except
finally
       Stream.Free;
end;

I posted a similar question some time ago, but that was regarding upload, not download. The code was fixed since then with the kind help of SO members, and the same code (used to deal with cookies, re-login, etc…) is being used now so I assume the problem is really in the download procedure shown above

Can someone please take a look at this tell me what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:40:43+00:00Added an answer on June 13, 2026 at 10:40 pm

    Just like with your other question, you should upgrade to a more recent version, if possible, and verify the problem still occurs before then asking for help. The current version is 10.5.9 r4861.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a delphi code that basically upload files to remote secure server using
I have this delphi code that basically download a file (using Delphi 2010 +
I have this horribly stripped delphi code that basically login to server, save cookie
I have bat-file, that make some operations. How to run this file from Delphi
I have Delphi 2007 code that looks like this: procedure WriteString(Stream: TFileStream; var SourceBuffer:
I have a delphi 7 form: and my code: when I run this form
I have some code that does custom drawing. Basically it is form fill program
We have some legacy code that compiles in Delphi 6. There are plans to
I am using Delphi to code a simple app that needs to accept dropped
Are there any utilities that reformat Delphi code ? EDIT I am using Delphi

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.