Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 May : Strange behaviour with ReadSmallInt

www.cryer.info
Managed Newsgroup Archive

Strange behaviour with ReadSmallInt

Subject:Strange behaviour with ReadSmallInt
Posted by:"Louis" (lou..@kwikpay.co.za)
Date:17 May 2005 06:13:27

Hi there

I've recently upgraded from Indy 9 to Indy 10.0.52 in Delphi 7.1, but some of my code stopped working. In the first two bytes of my request to the server is the size of the message and I used ReadSmallInt to obtain this.

The request that I send to the server looks like this:

#0'k0100²8'#0#1#0'€'#0#0#0#0#0#0#0#0#1#0'000000000000002900051711103300036711103405170582061710155  025E0000000001ABCDEFG 002900'

Here's the line of code in Indy 9:

iMessageLen := AThread.Connection.ReadSmallInt(False);

(AThread is of type TIdPeerThread)

And in Indy 10:

iMessageLen := AThread.IOHandler.Connection.ReadSmallInt(False);

(AThread is of type TIdContext)


In Indy 9 iMessageLen returned 107, but in Indy 10 it returns 0.

I started to play around with it and swopped the first two bytes of the message around like so:

'k'#0'0100²8'#0#1#0'€'#0#0#0#0#0#0#0#0#1#0'000000000000002900051711103300036711103405170582061710155  025E0000000001ABCDEFG 002900'

In this case I get the correct result in Indy 10.

So to summarise, in Indy 10 ReadSmallInt with input 'k'#0 returns 107, but with input #0'k' returns 0.

Any ideas?
Cheers
Louis

Replies:

www.cryer.info
Managed Newsgroup Archive