Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: idcmdTCPClient freeze - indy 10.1.5
| Subject: | Re: idcmdTCPClient freeze - indy 10.1.5 |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Mon, 26 Jun 2006 11:09:25 |
"Jacques" <jacques.noah@btinternet.com> wrote in message
news:449f263f@newsgroups.borland.com...
> i'm writing a client/server program using idcmdtcpclient/server
components.
Do not use TIdCmdTCPClient with TIdCmdTCPServer. They are not designed to
be used together. Use TIdCmdTCPClient with TIdTCPServer. Use TIdTCPClient
with TIdCmdTCPServer or TIdTCPServer.
> The problem is that i'm not sure how to read data sent by the server.
Yes, you do, because you are already doing it. SendCmd() automatically
reads the response into the LastCmdResult property.
> When i sent the test command the client just freezes.
Are you using TIdCmdTCPClient? If so, then you need to use TIdTCPClient
instead. You are sending commands to the server, and then reading responses
from the server. TIdCmdTCPClient is specifically designed for the opposite
scenerio - receiving commands from the server and sending responses back to
the server. Like TIdCmdTCPServer, TIdCmdTCPClient is a threaded component
that continuously reads from the socket in order to receive inbound data
asynchronously. You cannot call SendCmd() on a TIdCmdTCPClient because
SendCmd() also reads from the socket, so you would have two threads reading
each other's data and causing conflicts with each other. In your situation,
TIdCmdTCPClient's internal reading thread can end up reading data that
SendCmd() was expecting, and vice versa, thus locking up the reading.
> Also i dont know which methods to use to read and write to the
> server and client.
Yes, you do, because you are already using them.
Gambit