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

  • SEARCH
  • Home
  • 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 8845383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:43:36+00:00 2026-06-14T11:43:36+00:00

I am writing an application, which uses TIdTCPClient to communicated with another application via

  • 0

I am writing an application, which uses TIdTCPClient to communicated with another application via a socket.

I want the application to try to connect to a certain server until the connection is established (i. e. until the server has gone online).

In order to do this, I wrote following code:

procedure SendingThread.Execute();
var
I : integer;
Test : string;
IsConnected : Boolean;
begin
    TcpClient := TIdTCPClient.Create;
    TcpClient.Host := '127.0.0.1';
    TcpClient.Port := 9999;
    TcpClient.ConnectTimeout := 60000;

    IsConnected := false;
    while not IsConnected do
        begin
        try
            TcpClient.Connect;
            IsConnected := True;
        except
            on E:EIdSocketError do
                IsConnected := false;
        end;
    end;
...
end;

When I run this code with server being offline, I get EIdSocketError with error code 10061. The exception is thrown after TcpClient.Connect;.

How can I modify the code so that this exception in caught in the except cause?

  • 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-14T11:43:38+00:00Added an answer on June 14, 2026 at 11:43 am

    There are no code modifications necessary.* Your program is already catching the expected exception.

    What you’re seeing is the debugger intercepting the exception as soon as it’s thrown, before your program gets a chance to see that an exception exists and do anything about it. When the IDE intrerrupts you, it shows a dialog box giving you the option to continue running. Exercise that option, or press the “Run” button after you dismiss the dialog box.

    You can configure the debugger to ignore some or all exceptions, which is especially helpful when using Indy, which tends to use exceptions for normal flow control. How to do that has been covered here before.

    * Remy’s answer describes improvements you can make to your code to catch other possible exceptions.

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

Sidebar

Related Questions

I am writing an application which uses web services to connect a remote server.I
I'm writing an Air application which uses sockets. I need to connect to nexus.passport.com:443
I'm writing a c# application which uses automation to control another program. Naturally that
I'm writing an application which uses ASP.NET MVC with JSON.NET as the server, sending
I'm writing a web application in Rails which uses sqlite. I want the user
I'm writing a PHP application which uses AJAX to submit forms via POST when
I'm writing an application which uses sshj library for SSH connections. User opens Connect
I am writing an android application which uses a REST-based API on the server.
I am writing an Android application which uses several 3D models. Such a model
I am currently writing an API and an application which uses the API. I

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.