Article View: borland.public.cppbuilder.internet.socket
Article #29UDP.Broadcast corupted
From: jvdn
Date: Thu, 07 Aug 2008 13:57
Date: Thu, 07 Aug 2008 13:57
81 lines
3219 bytes
3219 bytes
Hi,
I have a problem with sending an Int value over SOAP.
I Chage the int to a AnsiString.
then I call
procedure TIdUDPBase.Broadcast(const AData: string; const APort: integer;
const AIP: String = '');
begin
Broadcast(ToBytes(AData), APort, AIP);
end;
this one calls
procedure TIdUDPBase.Broadcast(const AData: TIdBytes; const APort: integer;
const AIP: String = '');
var
LIP: String;
begin
LIP := Trim(AIP);
if LIP = '' then begin
LIP := '255.255.255.255'; {Do not Localize}
end;
SetBroadcastFlag(True);
SendBuffer(LIP, APort, AData); {Do not Localize}
BroadcastEnabledChanged;
end;
when I call the first function the data is still correct :
here are the bytes from the debugger:
0 1 2 3 4 5
[3][2][8][1][0][\0]
procedure TIdUDPBase.Broadcast(const AData: string; const APort: integer;
const AIP: String = '');
begin
Broadcast(ToBytes(AData), APort, AIP);
end;
but now after the ToBytes it gets into teh Implementation of Broadcast the
data is coropted.
here are the bytes from the debugger:
0 1 2 3 4 5 6 7
[3][2][8][1][0][0][1][\0]
When I debug the code inbetween I see Indy says that the langth = 5
repeatedly.
But I never see Indy put a end of string marker in the array. that is also
the problem.
the ToBytes() returns the wrong charecter array.
here there is a use of :
// Here the data is OK
SetLength(Result, LLength);
CopyTIdString(AValue, AIndex, Result, 0, LLength);
// From after this the data seems to be corupted.
inside
we get to
System::_LStrLAsg (Asm version)
IndyLength // here the given buffer is still correct.But I have a big ?
about the 5 I see for the size. In C++ it should be 5 + 1 (buffer length) +
1 => 6
and now I get to the System::Move that moves only 5 postion of dat a to the
buffer. the buffer is not filed with '\0' and the size is not set to 6 but
5. in all the cycles above. eevery one with it's own length test.
I belive I need a Buffer of
SetLength(Result, LLength + 1);
CopyTIdString(AValue, AIndex, Result, 0, LLength);
Result[lLength] := '\0';
But mybe this code is used for a lot more places. I have no idea of the
inpact for othere parts.
Can I get any advice.
Jvdn.
Technical Details
Message-ID:
<489aff67@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,557264648afd1970,start X-Google-Attributes: gid11508e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "jvdn" <geen@geenmail.com> Newsgroups: borland.public.cppbuilder.internet.socket Subject: UDP.Broadcast corupted Date: Thu, 7 Aug 2008 15:57:59 +0200 Lines: 83 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.3138 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 212.178.41.122 Message-ID: <489aff67@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1218117479 212.178.41.122 (7 Aug 2008 06:57:59 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 3063