🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: how to send buffer size message and buffer

#4949
From: duncan
Date: Fri, 19 Nov 2004 11:03
36 lines
2255 bytes
Hi Remy, thanks for all your usefull code,

I have looked through it, and I get most of it  but I am unsure
 about the following bit of code

what does the method for ReadRawFromSocket look like and 
what is SomeBuffer is this a global variable that sotres all FBuffer info from multiple ClientRead events?


    void __fastcall TServerForm.ServerSocketClientRead(TObject *Sender,
TCustomWinSocket *Socket)
    {
        int BufLen = Socket->ReceiveLength();
        if( BufLen <= 0 ) return;

        void *Ptr = FBuffer->Expand(BufLen);
        ReadRawFromSocket(Socket, Ptr, BufLen);

        while( FBuffer->RemainingBytes() >= sizeof(int) )
        {
            BufLen = ReadIntegerFromStream(FBuffer);
            if( FBuffer->RemainingBytes() < BufLen )
            {
                FBuffer->Position = 0;
                break;
            }

            if( BufLen > 0 )
            {
                ReadRawFromStream(FBuffer, SomeBuffer, BufLen);
                // process SomeBuffer as needed...
                FBuffer->Remove(FBuffer->Position);
            }
        }
    }
Technical Details
Message-ID: <419de0f6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <419b3068$1@newsgroups.borland.com> <419b32cf$1@newsgroups.borland.com> <419b934b$1@newsgroups.borland.com> <419cbb08$1@newsgroups.borland.com> <419cd9b2$1@newsgroups.borland.com> <419cf046@newsgroups.borland.com> <419cfe32$1@newsgroups.borland.com> <419d9e5b$1@newsgroups.borland.com> <419dc2d0$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,e51687cce2165a07
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "duncan" <no_spam@spamsucks.com>
Sender: "duncan" <no_spam@spamsucks.com>
Reply-To: "duncan" <no_spam@spamsucks.com>
Subject: Re: how to send  buffer size message and buffer 
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 194.129.249.241     
References: <419b3068$1@newsgroups.borland.com> <419b32cf$1@newsgroups.borland.com> <419b934b$1@newsgroups.borland.com> <419cbb08$1@newsgroups.borland.com> <419cd9b2$1@newsgroups.borland.com> <419cf046@newsgroups.borland.com> <419cfe32$1@newsgroups.borland.com> <419d9e5b$1@newsgroups.borland.com> <419dc2d0$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <419de0f6$1@newsgroups.borland.com>
Date: 19 Nov 2004 04:03:02 -0700
X-Trace: newsgroups.borland.com 1100865782 207.105.83.66 (19 Nov 2004 04:03:02 -0700)
Lines: 38
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail