On 4/8/2010 2:28 AM, Lukas Gebauer wrote:
>> In the recvstream method, it is using the recvinteger method, but the
>> sendstream method is not using the sendinteger method. I could not get
>> my code to work until I did this in the sendstream method:
>>      
> sendinteger is not needed, because size is encoded into begin of send
> buffer... see:
>
>          SendString(CodeLongInt(l) + s);
>
> It is TCP speed optimalization. ;-) If it does not work for you then
> error can be with bad byte order. See the "if Indy then" condition on
> the begin of InternalSendStream method.
>
>
>
>    

The code:

SendString(CodeLongInt(l) + s);

refuses to work, the value sent would be received on the server side as 
a negative number and that would cause the bad byte order
I don't use Indy at all, and my code has worked flawlessly for years 
until I upgraded to the latest version.

I am doing this on Windows 7 64bit and Delphi 2010, I am pretty sure 
it's not a bad byte order.

Replacing the line above with:

sendinteger(l);
SendString(s);

Completely fixes the issue, and it does indeed use the RecvInteger 
method in the recvstream method, I verified this and knew right away 
that is what the problem was.
It does not make sense to use:

SendString(CodeLongInt(l) + s);

for sending the size and then RecvInteger in the recvstream method which 
is here:

procedure TBlockSocket.RecvStream(const Stream: TStream; Timeout: Integer);
var
   x: integer;
begin
   x := RecvInteger(Timeout);
   if FLastError = 0 then
     RecvStreamSize(Stream, Timeout, x);
end;

I am just telling you it flat out does not work when using

SendString(CodeLongInt(l) + s); on windows 7 and Delphi 2010

Could this be related to how windows 7 socket stack works or something 
in Delphi 2009/2010 which is related to the unicode strings?

Why does my code work when I made this change?

Sorry if I am being a pain :-)


Later,

Tony





------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to