Question

Im learning delphi through books and am encountering a problem in this chapter: http://etutorials.org/Programming/mastering+delphi+7/Part+IV+Delphi+the+Internet+and+a+.NET+Preview/Chapter+19+Internet+Programming+Sockets+and+Indy/Building+Socket+Applications/#toc

It is this peace of code that gives me trouble because i dont know where to write it.

object IdTCPServer1: TIdTCPServer
  CommandHandlers = <
    item
      Command = 'test'
      Name = 'TIdCommandHandler0'
      ParseParams = False
      ReplyNormal.NumericCode = 100
      ReplyNormal.Text.Strings = (
        'Hello from your Indy Server')
      ReplyNormal.TextCode = '100'
    end
Was it helpful?

Solution

That is part of a DFM file of a form with a non-visual component called TIdTCPServer on it. Just place such a component on your form and use the property editor to set the properties to the given values. For example, you have to add a command handler (using the CommandHandlers property) and set its Command property to "test".

OTHER TIPS

That is part of the DFM file, which you don't edit directly. I just placed a TIdTCPServer on a form and the DFM shows:

object IdTCPServer1: TIdTCPServer
  Bindings = <>
  DefaultPort = 0
  Left = 80
  Top = 112
end

You can see this for yourself if you right click on your form and choose 'View as Text' (or if you inspect the .DFM files in an editor if you have your configuration set to save them as text.

When you start filling in more (non-default) properties of the TIdTCPServer, Delphi will store these in the DFM as well. I don't see a CommandHandlers property in my Delphi version (XE2, Indy 10.5.8.0), but yours has one (in the example).

[Edited to add] I see from your comment on another answer that you do not have a CommandHandlers property for TIdTCPServer either, this may indicate that the book author used a different Indy version than you do. You can see your version by right-clicking on any Indy component on the form.

CommandHandlers are indeed old. Googling "tidtcpserver commandhandlers" leads to e.g. "The CommandHandlers collection was moved to a new TIdCmdTCPServer component in Indy 10." That makes me suspect you have Indy 10 and the book references 9. You'll have to find Indy 10 examples for what you want to do. That should not be too difficult.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top