🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: i need ideas/comments with tclientsocket

#3249
From: Remy Lebeau (TeamB)
Date: Mon, 31 Oct 2005 19:37
30 lines
2040 bytes
"Alfred" <alf@no.spam.not.valid.email> wrote in message
news:4366672a$1@newsgroups.borland.com...

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

You are not taking into account the conditions where ReceiveLength() can
return a value < 1.  You need to do so.  You should also be accessing the
Socket parameter of the OnRead event handler, not the Socket property of the
TClientSocket.

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

You shold not be creating a new TMemoryStream on every event.  You need to
create a single TMemoryStream and then reuse it over and over.  That is the
only way you can preserve incomplete data between multiple events.

> 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 ?

By writing both pieces to the same TMemoryStream object, not to separate
streams.


Gambit
Technical Details
Message-ID: <43667285$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <43662baf$1@newsgroups.borland.com> <43664511@newsgroups.borland.com> <4366672a$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> <43664511@newsgroups.borland.com> <4366672a$1@newsgroups.borland.com>
Subject: Re: i need ideas/comments  with tclientsocket
Date: Mon, 31 Oct 2005 11:37:42 -0800
Lines: 32
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: <43667285$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1130787461 68.69.17.41 (31 Oct 2005 11:37:41 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail