🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: i need ideas/comments with tclientsocket

#3241
From: Hans Galema
Date: Mon, 31 Oct 2005 18:07
51 lines
2404 bytes
Jonathan Benedicto wrote:

> I just tried this code, and the app didn't hang:

But clicking the button a second time does nothing.

To see what is happening:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    AnsiString Msg = "This is a very long message.";

    int nsendtotal = 0;

     for( int i = 0; i < 20; ++i )
     {
         int nsend = ClientSocket1->Socket->SendBuf( Msg.c_str(), Msg.Length() );

         nsendtotal += nsend;

         Label1->Caption = IntToStr ( i ) + " - " + IntToStr ( nsendtotal );
         Label1->Repaint();
     }
}


void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
       TCustomWinSocket *Socket)
{
    int rl = Socket->ReceiveLength();

    int r2 = rl/ 2;

     if( r2 <= 0 )
        return;

     char *buffer = new char[ r2 ];

     int nreceived = Socket->ReceiveBuf( buffer, r2 );

     // private int receivedtotal;
     receivedtotal += nreceived;

     Memo1->Lines->Add( IntToStr ( r2 )
         + " recvd buf of " + IntToStr( nreceived )
         + " bytes. total: " + IntToStr ( receivedtotal ));

     delete[] buffer;
}

Hans.
Technical Details
Message-ID: <43665da7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
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> <43664ec9$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
Date: Mon, 31 Oct 2005 19:07:30 +0100
From: Hans Galema <notused@notused.nl>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Re: i need ideas/comments  with tclientsocket
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> <43664ec9$1@newsgroups.borland.com>
In-Reply-To: <43664ec9$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 145.98.201.248
Message-ID: <43665da7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1130782119 145.98.201.248 (31 Oct 2005 10:08:39 -0700)
Lines: 51
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail