🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to transport 0x00 through TIdBytes

#543
From: Marijan Sever
Date: Sun, 13 Jan 2008 09:05
123 lines
4305 bytes
Remy, than you very much on your support.

> Then you are not sending the bytes correctly, because Indy does not treat
> 0x00 any differently than other bytes.

Possible, this is the reason that I asking for help.

>No, it used void* instead, which meant you could pass in just about
>anything
> you wanted.

OK, void and I used to send char array.

> > Indy 10 uses TIdBytes for transport buffer (as far as I know).
> There are several different ways to send buffers in Indy 10.  TIdBytes is
> just one of them.

UPS...? What are the other ways? I checked TIdUDPServer Indy10 help and 
found
as follows(TIdUDPBase):

//----------------------------1
procedure Send(
    AHost: string,
    const APort: Integer,
    const AData: string
);
//----------------------------2
procedure SendBuffer(
    AHost: string,
    const APort: Integer,
    const ABuffer: TIdBytes
); virtual; overload;
//----------------------------3
procedure SendBuffer(
    AHost: string,
    const APort: Integer,
    const AIPVersion: TIdIPVersion,
    const ABuffer: TIdBytes
); virtual; overload;
//----------------------------
Allmost similar is in TidSocketHandle...
Would you be so kind and specify what are other options.

> > TIdBytes cbuf;
> > char c[8];
> You don't need a separate char[].  You can fill the TIdBytes directly, ie:

Yes, I use this way, but in the sample seemed convenient to use char because
of  clearity

>     TIdBytes cbuf;
>     cbuf.Length = 8;
>     cbuf[0] = 0x01;
>     cbuf[1] = 0x00;
>     cbuf[2] = 'a';
>     cbuf[3] = 'b';
>     cbuf[4] = 0x00;
>     cbuf[5] = 'c';
>     cbuf[6] = 'd';
>     cbuf[7] = ?; // what are you putting here???  You allocate 8 slots but
> only fill in 7 of them

cbuf[7] - sorry forgot in my sample.It can be 'e'.

>  Getting where?  Were are you looking at the data from?

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?

>  The receiver end?

The same as in Local variable window


> If you are sending 8 bytes but only receiving 2 bytes, then that is all
> you
> are receiving.  What do you have set for the TIdUDPServer.BufferSize
> property?

Default, 8192 bytes

>  What does your OnUDPRead event handler look like?

//----------------------------------------------------
void __fastcall UDPClientTh::Execute()
{
try
{
    pUDPSock->ClSock->ReceiveBuffer(RxBuf,500);
    Synchronize(&ProcessMsg);
}
catch (Exception &E)
{
   //Do something...
}
}
//----------------------------------------------------

//UDDPSock is main UDP thread
//ClSock is TIdUDPClient
//UDPClientTh is receiving thread
//RxBuf is TIdBytes, initialized as follows: RxBuf.Length=8192;

> Have you tried
> using a packet sniffer to verify all of the bytes are arriving on the
> receiver's network adpater to begin with?

Yes, Ethereal... Same.

> > It seems that TIdBytes uses 0x00 as null termination for string.
>
> No, it does not.  The full Length of the buffer is always used.

Hm, I believe you, but can not achieve this till now.
Technical Details
Message-ID: <4789d472@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4780bfd0@newsgroups.borland.com> <4782646b$1@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
Reply-To: "Marijan Sever" <marijan.sever@codel.hr>
From: "Marijan Sever" <marijan.sever@codel.hr>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <4780bfd0@newsgroups.borland.com> <4782646b$1@newsgroups.borland.com>
Subject: Re: How to transport 0x00 through TIdBytes
Date: Sun, 13 Jan 2008 10:05:53 +0100
Lines: 126
Organization: Codel
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 89.172.35.237
Message-ID: <4789d472@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1200215154 89.172.35.237 (13 Jan 2008 01:05:54 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail