Board index » delphi » Need help with Indy 10

Need help with Indy 10


2005-10-21 11:18:31 PM
delphi190
I am writing a client where i need to send an unsigned 16 bit value to
a server with TCPClient of Indy 10 in Delphi 2005:
********************************************
First try:
TCPClient.IOHandler.Write(value);
where value is a smallint with data assigned..
Delphi (Indy) gives me ECheckError.
************************************************
Second try:
BufferWidth,
BufferHeight: short;
BufferWidth := 1280;
BufferHeight := 768;
TCPClient.IOHandler.Write(RawToBytes(BufferWidth,sizeof(BufferWidth)));
No error is displayed, but... on the server side (C++) i got a complete
different value:
int w = is->ReadU16() //gives me 5
int h = is->ReadU16() //gives me 3
*************************************************************
This only happens with data type of 16. Am i using the rigth data types
for 16 bit value? I am new to delphi so this can be the problem.
Thanks and best regards,
JF
 
 

Re:Need help with Indy 10

The error breaks here:
function ToBytes(const AValue: Short): TIdBytes; overload;
begin
{$IFDEF DotNet}
Result := System.BitConverter.GetBytes(AValue);
{$ELSE}
SetLength(Result, SizeOf(Shortint));
PShortint(@Result[0])^ := AValue; <-- ERROR HERE!
{$ENDIF}
end;
THANKS
joao
 

Re:Need help with Indy 10

Hoi Joćo
You need to repost your question using the Borland news server, if you want
to find somebody to help you with an answer.
Take a look here:
<tinyurl.com/8m5nw>
which links to
<delphi.wikicities.com/wiki/Delphi_Newsgroups>
 

Re:Need help with Indy 10

tx.
I solved my problem. This protocol needs big endian bit values.. so i
should swap it before sending.
Tx anyway.
 

Re:Need help with Indy 10

For future posts, remember to post directly to the Borland news server.
Take a look here:
<tinyurl.com/8m5nw>
which links to
<delphi.wikicities.com/wiki/Delphi_Newsgroups>