Article View: borland.public.cppbuilder.internet.socket
Article #3239Re: i need ideas/comments with tclientsocket
From: Jonathan Benedicto
Date: Mon, 31 Oct 2005 17:05
Date: Mon, 31 Oct 2005 17:05
38 lines
2037 bytes
2037 bytes
Hans Galema wrote:
> Indeed. That is correct. But your code should read all bytes
> indicated by ReceiveLength(). Not the minimum with the messagelength.
> So then first it would go wrong.
I just tried this code, and the app didn't hang:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString Msg = "This is a very long message.";
for( int i = 0; i < 20; ++i )
{
ClientSocket1->Socket->SendBuf( Msg.c_str(), Msg.Length() );
Label1->Caption = i;
Label1->Repaint();
}
}
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
int rl = Socket->ReceiveLength();
rl /= 2;
if( rl <= 0 )
return;
char *buffer = new char[ rl ];
Socket->ReceiveBuf( buffer, rl );
Memo1->Lines->Add( "recvd buf of " + IntToStr( rl ) + " bytes." );
delete[] buffer;
}
Jonathan
Technical Details
Message-ID:
<43664ec9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-out.spamkiller.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43662baf$1@newsgroups.borland.com> <43663272$1@newsgroups.borland.com> <43664213$1@newsgroups.borland.com> <43664528$1@newsgroups.borland.com> <436646de$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: "Jonathan Benedicto" <incorrect@no.server> Newsgroups: borland.public.cppbuilder.internet.socket References: <43662baf$1@newsgroups.borland.com> <43663272$1@newsgroups.borland.com> <43664213$1@newsgroups.borland.com> <43664528$1@newsgroups.borland.com> <436646de$1@newsgroups.borland.com> Subject: Re: i need ideas/comments with tclientsocket Date: Mon, 31 Oct 2005 12:05:20 -0500 Lines: 40 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: 69.158.116.150 Message-ID: <43664ec9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1130778313 69.158.116.150 (31 Oct 2005 09:05:13 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-out.spamkiller.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail