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 397153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:37:20+00:00 2026-05-12T16:37:20+00:00

I use Indy’s TIdTCPServer (D2009, Indy 10) to communicate with client applications. In the

  • 0

I use Indy’s TIdTCPServer (D2009, Indy 10) to communicate with client applications. In the OnExecute method I create a task and queue it. A worker thread executes the task and puts it in the send queue. The send queue then sends the response to the client.

In the send thread I loop through the server’s context list and look for the context matching the IP and port information stored in the task. Then follow a number of send commands that sometimes throw access violations (I’m guessing that the context gets destroyed during sending).

Now to the question: how can I make sure that the context is not closed before I have sent the response? Is it possible with Indy to send from a separate thread or should everything be done in the Indy thread?

  • 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-05-12T16:37:20+00:00Added an answer on May 12, 2026 at 4:37 pm

    You can try keeping the TIdTCPServer.Contexts list locked while you are sending data, as The Context is not freed until after it is removed from the list. The downside is that no client connects/disconnects/sends will be processed while that one send is in progress.

    Alternatively, simply wrap your sending code in a try/except block and ignore any errors that may occur.

    Alternatively, if you can re-write your code to move the send queue into the Context itself, that would be best, yes. Then your OnExecute event handler could check the queue periodically and send data when available. That will also help with performance, as you are not serializing your sends anymore if you have outgoing data ready for multiple clients at the same time.

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

Sidebar

Related Questions

I use Indy for TCP communication (D2009, Indy 10). After evaluating a client request,
i use this code in a thread (through Indy Onexecute event) . is there
Use case: class MyTask(Task): queue = 'default_queue' def run(self): # do work Normally I
I have a client/server application written in delphiXe2 using Indy TIdTCPServer and TIdTCPClient that
I use TIdTCPServer and the following code to read client input : repeat cl3:=cl3+AContext.Connection.IOHandler.ReadLnSplit(WasSplit,#0,-1,-1,TEncoding.UTF8);
I use Indy 9 with Delphi 5. In my application I want to communicate
Can i use IdHTTP in the OnExecute Event (Indy) ? like this : procedure
I'm just starting to learn how to use the Indy 10 components in Delphi
I have a Delphi application with a Indy TCPServer and TCPClient. I use the
I started using Overbyte components , used to use Indy but blocking issue made

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.