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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:58:01+00:00 2026-06-01T09:58:01+00:00

Delphi XE2, so Indy 10. My client sends a command which is processed by

  • 0

Delphi XE2, so Indy 10.

My client sends a command which is processed by a TIdCommandHandler of my TIdCmdTCPServer.

I want to be able to perform some logic and return either a success or fail response and check for that back at the client.

Can someone please point me at a few lines of code as an example? Thanks in advance.

  • 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-01T09:58:02+00:00Added an answer on June 1, 2026 at 9:58 am

    Well, here’s the simplest demo.

    enter image description here

    Add an IdCmdTCPServer to your form, and add one command, set its name in the Command property, I originally thought I should handle Response in OnCommand event like this:

    procedure TForm1.IdCmdTCPServer1CommandHandlers0Command(ASender: TIdCommand);
    begin
       //ASender.Response.Add('Hello');  // wrong way
       ASender.Reply.SetReply(0,'HELLO');
    
    end;
    

    Update Remy pointed out I shouldn’t be using Response.

    So you want to return success or failure, it’s traditional to use a numeric result followed by the string value. Each string in the response strings list has an implied end-of-line transmitted back to the client:

    procedure TForm1.IdCmdTCPServer1CommandHandlers0Command(ASender: TIdCommand);
    begin
      if DoSomething then
        ASender.Reply.SetReply(0,'OK')
      else
        ASender.Reply.SetReply(999,'ERROR');
    
    end;
    

    The idea with the IdCommandHandler and a CmdTCPServer/Client is that you follow the “RFC” style of protocols, which are ANSI/ASCII text-based. An RFC-style internet protocol’s reply is typically encoded over the wire as text with both a numeric and string value. ASender.Response could be used if you needed to take the content of a string list and return that as the response.

    As for the client, a question here suggests that TIdCmdTcpClient is not the most natural way to build the client for this server. From their names, you’d have thought they were made for each other, but it’s not exactly. For most simple TIdCMDTCPServers that you could build, you would find that a plain-vanilla TIdTCPClient is the simplest building block to start your client with.

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

Sidebar

Related Questions

Delphi XE2, so I guess that is Indy 10(?). One server, 10 clients. I
We are upgrading our application from Delphi 2007 to Delphi XE2, which includes unicode
I'm trying to develop an application in Delphi XE2 that will be able to
The Delphi XE2 skinning option is fantastic, but there are cases where you want
In Delphi XE2 the automatically generated build numbers functionality now uses some kind of
I am using Delphi XE2 with help installed. I want to see the hints
I have a Delphi XE2 Firemonkey application that I want to run on both
I'm migrating an old Delphi application (using ZeosDB) to Delphi XE2. I want to
I want to use the enumerator for a generic collection with Delphi XE2. I
I am trying to use the randomrange function in Delphi XE2 but for some

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.