Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Re: Indy 9 TidTcpClient / TidTcpServer stream problems

www.cryer.info
Managed Newsgroup Archive

Re: Indy 9 TidTcpClient / TidTcpServer stream problems

Subject:Re: Indy 9 TidTcpClient / TidTcpServer stream problems
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Mon, 5 Nov 2007 10:54:50

"RandomAccess" <Not@TellingYou.com> wrote in message
news:472ee2b5@newsgroups.borland.com...

> I'm trying to have my Client send a data stream to the server,
> but the server keeps giving Stream Read Error exception.

That is because you are reading the stream wrong.  On the client side, you
are calling WriteStream() with its AWriteByteCount parameter left to its
default value of False, so the stream size is not being transmitted.
However, on the server side, you are calling ReadStream() with its
AByteCount parameter left to its default value of -1 and its
AReadUntilDisconnect parameter left to its default value of False. That
combination tells ReadStream() to expect the stream size to have been
transmitted before the actual data.  Thus, ReadStream() is interpretting the
first 4 bytes of the stream data as being the stream size, which is why you
are getting a reading error.

To fix the problem, you need to either:

1) set the AWriteByteCount parameter of WriteStream() to True

2) pass the stream size as a parameter of your command, and then pass that
value to the AByteCount parameter of ReadStream() instead of -1.

>    ASender.Reply.SetReply(-997, 'Unrecognized Connection');

You are setting the response code to a negetive value, but the client is
expecting a positive value instead.  Also, the presense of a negative sign
will produce a 4-character string value when transmitted, whereas SendCmd()
is designed for 3-digit codes instead.

>    ASender.Reply.SetReply(9999, 'Invalid Table Identifier');

Again, you are using a 4-digit value instead of a 3-digit value.

>    ASender.Reply.SetReply(9999, 'Invalid Item Identifier');

And again.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive