🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: i need ideas/comments with tclientsocket

#3243
From: Alfred
Date: Mon, 31 Oct 2005 17:49
34 lines
2305 bytes
Thank you for reply
>
>   int size = the_size_of_the_message;
>
>   ->SendBuf ( &size, sizeof(size);
>   ->SendBuf ( message, size );

Yes that is a better idea than mine (thank you Jonathan and you).

>Using a TMemoryStream is fine.
>What you have to consider first is that if OnRead triggers that
>you /have/ to read all bytes indicated by ReceiveLength().
>That can be very easily handled by just reading /all/ into a TMemoryStream.
>(Adjust Size first, And Position after).
>Now after having put all in the memorystream check the first four bytes.

ok i am trying to write it :
on clientsocketread :
        int Len = ClientSocket->Socket->ReceiveLength();

        char *Buffer = new char[Len];
        Socket->ReceiveBuf( Buffer, Len );

        TMemoryStream *Data = new TMemoryStream;
        Data->Size = Len;
        Data->Position = 0;
        Data->Write( Buffer, Len );

now my data are stored in it and like you written I can read the packet size with :
        int size = *(int*)Data->Memory;
here is my new problem , for example : the first time I get only the first part of a package and after few seconds I get the last part of this  package. How I can join both parts ? my code now works but I haven't a single message, i have a lot of splitted message.
thank you very much
Alfred
Technical Details
Message-ID: <4366672a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43662baf$1@newsgroups.borland.com> <43664511@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: "Alfred" <alf@no.spam.not.valid.email>
Sender: "Alfred" <alf@no.spam.not.valid.email>
Reply-To: "Alfred" <alf@no.spam.not.valid.email>
Subject: Re: i need ideas/comments  with tclientsocket
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 82.52.136.128     
References: <43662baf$1@newsgroups.borland.com> <43664511@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4366672a$1@newsgroups.borland.com>
Date: 31 Oct 2005 10:49:14 -0700
X-Trace: newsgroups.borland.com 1130784554 207.105.83.66 (31 Oct 2005 10:49:14 -0700)
Lines: 35
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail