Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Nov : Indy V9 - is this possible?

www.cryer.info
Managed Newsgroup Archive

Indy V9 - is this possible?

Subject:Indy V9 - is this possible?
Posted by:"Michael Fritz" (spam_athome@yahoo.de)
Date:Thu, 2 Nov 2006 14:53:15

Hi,

using Indy V9 with D7, I'm trying to send a command to a TIdTCPServer which
was set up using this coding:

procedure TUDPMainForm.CreateIPServer;
  procedure AddCMD(CMD : string; Proc : TIdCommandEvent);
  begin
   with FIPServer.CommandHandlers.Add do
   begin
     Command := CMD;
     Name := Format('cmd%s',[AnsiUpperCase(CMD)]);
     OnCommand := Proc;
   end;
  end;
  begin
    FIPServer := TIdTCPServer.Create(self);
    with FIPServer do
    begin
      DefaultPort := 8091;
      AddCMD('CLIENT_CONNECTION', CMDClientConnection);
      CommandHandlersEnabled := True;
      OnConnect := IPServerClientConnection;
      OnNoCommandHandler := IPServerNoCommandHandler;
      Active := True;
    end;
  end;

procedure TUDPMainForm.CMDClientConnection(AThread: TIdCommand);
  var
    Connection : TCommandConnection;
  begin
    AThread.Thread.Connection.ReadBuffer(Connection,
    SizeOf(TCommandConnection));
  [..]
  end;

I'm sending the command 'CLIENT_CONNECTIO' from this coding:

  var
   Command : TCommandString;
   Connection : TCommandConnection;
  begin
    Result := False;
    Connection.AppKey := 'XYS';
    Connection.Username := 'user';
    Connection.Client := GStack.LocalAddress;
    //
    FIPClient.SendCmd('CLIENT_CONNECTION');
    FIPClient.WriteBuffer(Connection, SizeOf(Connection), False);
  end;

My assumption was that calling FIPClient.SendCmd reaches the procedure
CMDClientConnection from above and it does so.

My problem is that the coding (.ReadBuffer) in CMDClientConnection does not
work since the FIPClient.WriteBuffer has not been triggered so far.

So, how can I use the CommandHandlers to first send a command and second to
send some data to the server immediately after sending the command? The
data is not always of type string. I can occur that the data is a record of
mixed data types.

Thx for your comments.
--
cu,
Michael

Replies:

www.cryer.info
Managed Newsgroup Archive