🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3380

Re: INDY IdTCPServer1 read bytes

#3380
From: Remy Lebeau (TeamB)
Date: Wed, 21 Sep 2005 16:50
45 lines
2865 bytes
"Billy Holliday" <NoSpam@Hohoho.com> wrote in message
news:43312e17$1@newsgroups.borland.com...

> I can use the  AThread->Connection->ReadChar(); function in
> IdTCPServer1Execute to get the data..

You did not explain what kind of data you are receiving in the first place.

> But i have a binary datapacked, contaning 0x00 in the data.

So?  ReadChar() does not care about 0x00.

> With ReadChar() i can't known, how much data i received.

ReadChar() always reads 1 byte at a time, regardless of the value of the
byte.

> Is the a function or property to get the size???

That depends  on what kind of data you are actually receiving.  You could
use AThread->Connection->ReadFromStack() and then check the
AThread->Connection->InputBuffer->Size to find out how much was actually
read.  This approach reads everything that is currently available on the
socket, without regard to the contents of the data.  But that is not very
efficient, nor is it reliable since TCP frequently breaks up data into
smaller blocks, or combines multiple blocks together, during transmission.
ReadFromStack() is directly effected by that.

Most protocols have a defined layout to the data that is being sent.  Your
reading code should more closely resemble the actual data layout that you
are expecting.  For instance, if you are expecting a string, then have Indy
read a string.  Indy will wait until the full string is received, even if it
is broken up into multiple smaller blocks or it is combined with other
blocks. On the other hand, some protocols have a fixed-length data record,
so you could use ReadBuffer() instead.  On another hand, some protocol send
data lengths embedded inside the data.  You could read the lengths and then
use ReadBuffer() or ReadStream() to receive the rest of the data for a
particular record.

Again, it all depends on what the data actually looks like in the first
place.  Please provide more details.


Gambit
Technical Details
Message-ID: <43318f1b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <43312e17$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,33f175a151104b01
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <43312e17$1@newsgroups.borland.com>
Subject: Re: INDY IdTCPServer1 read bytes
Date: Wed, 21 Sep 2005 09:50:12 -0700
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <43318f1b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1127321371 68.69.17.41 (21 Sep 2005 09:49:31 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail