🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: i need ideas/comments with tclientsocket

#3139
From: Remy Lebeau (TeamB)
Date: Thu, 03 Nov 2005 05:38
39 lines
3198 bytes
"Hans Galema" <notused@notused.nl> wrote in message 
news:4368805e$1@newsgroups.borland.com...

> That is of lot of hassle compared by sending the terminating
> zero of a char buf.

Actually, there is a little more overhead involved when constructing an 
AnsiString from a null-terminated string without a length.  AnsiString would 
have to calculate the length of the characters before it can then allocate 
the memory to copy the characters into.  By sending and using the string 
length with the characters, that extra calculation is not needed since the 
length is already known ahead of time.

Besides, the code I gave Alfred is not designed to handle just strings 
alone, but any dynamic-length data in general.  Converting the data to 
AnsiString for display purposes was just his way of testing the code.  The 
code itself doesn't care if the data belongs to an AnsiString or not.

> Moreover if the sender sends a strings in a char buf then the receiver
> likely handles them as such and will be glad seeing a terminating zero.

Not necessarily.  If the original characters were in an appropriately-sized 
buffer, then chances of there being a terminating null character are 
actually less, since the buffer can be processed without a null terminator 
being present.  And if the size of the buffer is known on the receiver's 
side, then the null terminator is still not needed when receiving the 
characters.  Sure, the receiver can allocate extra memory to put a null 
terminator at the end of the buffer, but that is no needed.

> As you can see in my first post concerning this zero I never
> said that it was needed but that it came in handy.

That depennds on how the characters are actually being used.  The sender 
sound not be making assumptions about how the receiver will use the 
characters, and vice versa.


Gambit 
Technical Details
Message-ID: <4369a258$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!t-online.de!195.92.193.196.MISMATCH!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43662baf$1@newsgroups.borland.com> <43667112$1@newsgroups.borland.com> <4366ccd3$1@newsgroups.borland.com> <4366d53d$1@newsgroups.borland.com> <43672d94$1@newsgroups.borland.com> <4367327d@newsgroups.borland.com> <436739a0@newsgroups.borland.com> <4367a249$1@newsgroups.borland.com> <4368805e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5c33b8c6a9ca7fdb
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: <43662baf$1@newsgroups.borland.com> <43667112$1@newsgroups.borland.com> <4366ccd3$1@newsgroups.borland.com> <4366d53d$1@newsgroups.borland.com> <43672d94$1@newsgroups.borland.com> <4367327d@newsgroups.borland.com> <436739a0@newsgroups.borland.com> <4367a249$1@newsgroups.borland.com> <4368805e$1@newsgroups.borland.com>
Subject: Re: i need ideas/comments  with tclientsocket
Date: Wed, 2 Nov 2005 21:38:35 -0800
Lines: 41
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4369a258$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1130996312 68.69.17.41 (2 Nov 2005 21:38:32 -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!t-online.de!195.92.193.196.MISMATCH!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail