Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Re: Open a TCP Socket

www.cryer.info
Managed Newsgroup Archive

Re: Open a TCP Socket

Subject:Re: Open a TCP Socket
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Fri, 1 Feb 2008 11:14:39

"Kim Jensen" <kim@comcasystems.com> wrote in message
news:47a26f1d$1@newsgroups.borland.com...

> The only thing the instruction says "You simply send an ASCII string
> to the controller followed by a carriage return and line feed.

Ok.  Use the WriteLn() method to send commands, ie:

    IdTCPClient.IOHandler.WriteLn('MyCommandHere');

> The Controller will either respons with a ' : ' or a ' ? ' .

If the controller is sending back only a single character, then use the
ReadChar() method, ie:

    var
        Reply: Char;
    begin
        IdTCPClient.IOHandler.WriteLn('MyCommandHere');
        Reply := IdTCPClient.IOHandler.ReadChar;
        if Reply = ':' then
            // ok
        else if Reply = '?' then
            // error
        else
            // unknown
    end;

> Send the command TC1 and it will response with the reason."

In what format, though?  An ASCII string with a CRLF terminator, like for
commands?  IF you don't know EXACTLY how the data is formatted, you can't
read it properly.

> If I use telnet and send the command ID then I will get 6 lines back

Containing what, though?  Please show a real example.

> So it looks like I receive a CRLF before the :

That is more likely your telnet program simply echoing the CRLF that the
command had, or is manually inserting CRLF when receiving data.  The actual
data from the controller most likely does not contain actual CRLF in it.
But you need to use a packet sniffer, not a telnet program, to verify that
for sure.

> I need to read the respons until I either receive a : or ?

Again, there is no way to answer that yet without knowing EXACTLY what the
controller is really sending.  Again, use a packet sniffer to see that.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive