🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to transport 0x00 through TIdBytes

#545
From: Remy Lebeau (TeamB)
Date: Mon, 14 Jan 2008 17:36
54 lines
2834 bytes
"Marijan Sever" <marijan.sever@codel.hr> wrote in message 
news:4789d472@newsgroups.borland.com...

> UPS...? What are the other ways?

Sorry, I forgot that UDP does not have as many options as TCP.  In TCP, you 
could use a TStream, TIdBytes, or String.  In UDP, you don't have the 
TStream option.

> I have already try exactly as in your sample and in the debugger
> mode in the Local variable window I have as follows:
>
>      cbuf
>      |-----Data
>            |------[0]-------'\x01'1(0x01)
>            |------[1]-------'\x00'0(0x00)
>
> ...and nothing else. Have you tried this and get other results?

Did you try expanding the range of the Inspector to 8 slots?  You know the 
TIdBytes is allocated to 8 bytes long, but only 2 bytes are being displayed. 
That should tell you that it is the Inspector, not the code, that is 
stopping on a 0x00 byte.

>    pUDPSock->ClSock->ReceiveBuffer(RxBuf,500);

What are you setting the Length of RxBuf to beforehand.  You have to set it 
before calling ReceiveBuffer() so it knows the maximum numbe of bytes to 
read.  What value is ReceiveBuffer() returning?  That is the number of bytes 
that are actually read into the TIdBytes.  You should be resizing the 
TIdBytes to the desired Length every time beforehand, and then resizing it 
to whatever ReceiveBuffer() returns.  ReceiveBuffer() will not size the 
TIdBytes for you.  For example:

    try
    {
        RxBuf.Length = 8192;
        RxBuf.Length = pUDPSock->ClSock->ReceiveBuffer(RxBuf, 500);
        //...
    }
    catch(...)
    {
        //...
    }

> catch (Exception &E)

Always catch exceptions by 'const' reference instead:

    catch (const Exception &E)


Gambit 
Technical Details
Message-ID: <478b9e1a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4780bfd0@newsgroups.borland.com> <4782646b$1@newsgroups.borland.com> <4789d472@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,bc4788af487cfd6c
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4780bfd0@newsgroups.borland.com> <4782646b$1@newsgroups.borland.com> <4789d472@newsgroups.borland.com>
Subject: Re: How to transport 0x00 through TIdBytes
Date: Mon, 14 Jan 2008 09:36:44 -0800
Lines: 56
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
NNTP-Posting-Host: 207.178.157.90
Message-ID: <478b9e1a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1200332314 207.178.157.90 (14 Jan 2008 09:38:34 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail