Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Feb : Re: TIdCmdTCPClient sending to server

www.cryer.info
Managed Newsgroup Archive

Re: TIdCmdTCPClient sending to server

Subject:Re: TIdCmdTCPClient sending to server
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Tue, 19 Feb 2008 10:56:22

"Moore" <moore@hotmail.com> wrote in message
news:47bab963$1@newsgroups.borland.com...

> what i have done is on form creation connect to the server (form create),
> receive the hello string with readln(client onconnect), and send the
> petition
> for info with writeln (from create), which i receive immediately (readln),
> no
> command handler for this first command is created, for later commands i
> have created command handlers for each one, and they are received and
> treated adecuately

Although you can certainly handle the hello that way (since OnConnect is
triggered before the CommandHandler reading thread is created), you could
use CommandHandler items for the hello and info reply as well, and not use
the OnConnect event at all.

> all this functions well, except that sometimes as it seems messages
> overlap

They cannot overlap on the client side, since the reading thread is not
running yet until after the OnConnect handler exits.  Given the ordering of
the commands/replies being sent, they might be overlapping on the server
side, though.  Can you please show an example of something you think is
overlapping?

> which made me think to include the first command (DEVSTATUS) in a
> command handler, the problem with that command is that to receive it the
> client must send a command (CLIENT)

Which you can send in OnConnect normally, and then handle the reply in a
CommandHandler.

> which i make in the oncreate, but the results are not the desired ones

What is different exactly than what you are expecting?  Again, please
provide an actual example

> the app is much more slow in the GUI

Since the reply would be handled in the CommandHandlers reading thread,
there should be no GUI slowdown at all, unless you are synching with the
main thread too much.

> and data never received correctly,

Again, what exactly is not working correctly?  You are not providing enough
details.

> Is there a better approach to combine receiving commands with petition
> and those without petition maintaining the flow of data from the server
> without messages overlapping and the GUI being slow

Do as much as you can with CommandHandlers so they are threaded accordingly.
Then only thing you should be sending outside of the CommandHandlers is the
initial command that gets the server going.  After that, since the server
sends the rest of the commands and the client replies to them, the
CommandHandlers should be managing those.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive