Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Apr : Re: Indy10 / D2006 / IdCmdTCPClient / IdCmdTCPServer
| Subject: | Re: Indy10 / D2006 / IdCmdTCPClient / IdCmdTCPServer |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Fri, 7 Apr 2006 11:09:49 |
"Mark Gebauer" <mark.gebauer@gmx.net> wrote in message
news:443581fd@newsgroups.borland.com...
> I would like to use an IdCmdTCPClient in combination with IdCmdTCPServer.
Sorry, but you cannot do that. They are not designed to work together. You
need to use TIdTCPClient with TIdCmdTCPServer, and TIdTCPServer with
TIdCmdTCPClient.
> The Client should connect to the server, send some commands,
> and in the other direction the server should send some commands
> to the client.
That is a very problematic design. You will likely have to use TIdTCPClient
and TIdTCPServer for that, not the Cmd variants at all.
> But unfortunately that doesn't work. I'm running into troubles
> when trying to get a valid response from the server.
The Cmd variants are asynchronous. They each have a reading thread
internally that continuously reads from the socket. Such reading will
interfer with SendCmd()'s own reading.
> My Client sends a command, for example:
>
> IdTCPCmdClient1.SendCmd('AddChannel CH00', 200);
You cannot use SendCmd() with TIdCmdTCPClient at all. If you need to send
commands from the client, and receive their responses immediately, then you
cannot use TIdCmdTCPClient.
> Now the client either freezes (waiting for a correct response) or
> throws an exception (wrong reply code).
TIdCmdTCPClient's internal thread ends up receiveing part, or all, of the
response data. Just enough to make SendCmd() wait for data that it will
never receive, or to parse incomplete data.
> Can somebody please help me to understand why this code
> doesn't work with IdCmdTCPClient?
Because it is not supposed to.
> Or are IdCmdTCPClient/IdCmdTCPServer not able to send commands?
They are not. Not the way that you are using them.
Gambit
none