🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Sending Text Over A Socket

#5035
From: Remy Lebeau (TeamB)
Date: Sat, 23 Oct 2004 19:23
31 lines
2226 bytes
"David Mulford" <dmul007@yahoo.com> wrote in message
news:4175dd32@newsgroups.borland.com...

> I went and tried again, TClientSocket is still only
> sending binary over sockets.

Everything, including text, is binary as far as sockets are concerned.
Everything is handled at the binary level to begin with.  Text is nothing
more than the range of binary values that are human readible, that is all.

>         Socket->SendText("Send Test");

I would strongly suggest that you redesign your communication protocol.
Whenever you send variable-length data, such as strings, you should always
either:

1) preceed the string data with a fixed-length binary value that specifies
how many bytes are in the actual string.  That way, the receiver can read
the binary value first and know how many additional bytes need to be read
for the actual string data.

2) terminate the string data with a unique byte, or sequence of bytes, that
are quaranteed not to appear in the actual string data.  The receiver can
then continue reading from the socket until that byte/sequence is
encountered, and then stop reading from that point.

Personally, I prefer #1 myself whenever possible.


Gambit
Technical Details
Message-ID: <417aaf72$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.newsfeeds.com!in.nntp.be!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4174934f$1@newsgroups.borland.com> <417493aa@newsgroups.borland.com> <2tlc6sF21cg6jU1@uni-berlin.de> <4175dd32@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ece8d99f83d2b6c4
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: <4174934f$1@newsgroups.borland.com> <417493aa@newsgroups.borland.com> <2tlc6sF21cg6jU1@uni-berlin.de> <4175dd32@newsgroups.borland.com>
Subject: Re: Sending Text Over A Socket
Date: Sat, 23 Oct 2004 12:23:09 -0700
Lines: 33
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: <417aaf72$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1098559346 68.69.17.41 (23 Oct 2004 12:22:26 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.newsfeeds.com!in.nntp.be!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail