Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-17 Thread Michael Van Canneyt
On Sun, 16 Jun 2013, Michalis Kamburelis wrote: Michael Van Canneyt wrote: If an implementation of Read does not return the requested data when in fact it is available, then the implementation of Read is broken. I guess it depends how do you interpret TStream.Read documentation... http://w

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-16 Thread Michalis Kamburelis
Michael Van Canneyt wrote: If an implementation of Read does not return the requested data when in fact it is available, then the implementation of Read is broken. I guess it depends how do you interpret TStream.Read documentation... http://www.freepascal.org/docs-html/rtl/classes/tstream.read

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-16 Thread Michael Van Canneyt
On Sun, 16 Jun 2013, Michalis Kamburelis wrote: Michael Van Canneyt wrote: The above implementation should not be changed, it is Delphi compatible: TStream.ReadBuffer works on the assumption that Read will always return the amount of bytes requested if they are available. So, if you want to

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-16 Thread Michalis Kamburelis
Michael Van Canneyt wrote: The above implementation should not be changed, it is Delphi compatible: TStream.ReadBuffer works on the assumption that Read will always return the amount of bytes requested if they are available. So, if you want to make changes, there is no reason why TStream.Read sh

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-16 Thread Michalis Kamburelis
Ewald wrote: The question that arises here is whether all the `ReadByte`, `ReadWord`, `WriteByte`, `WriteWord`, `WriteBuffer`, ... should also `try harder`? Same issue there: no data is returned about the actual number of bytes read. Anyway, I leave that to someone who knows the internals of thes

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-16 Thread Michael Van Canneyt
On Sun, 16 Jun 2013, Michalis Kamburelis wrote: Hi, I'm often reading fixed-size structures using TStream.ReadBuffer, working under the assumption that it will fail only if it's not possible to read the requested amount of bytes (that is, if the stream ended prematurely). This is actually

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-16 Thread Ewald
On 16 Jun 2013, at 03:18, Michalis Kamburelis wrote: > Ewald wrote: >> And what with non-blocking pipes pipes? Wait for a *some* period >> until you get all data? It is up to the programmer to do this INHO. > > If you want to get partial data (instead of waiting until all requested data > is av

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-15 Thread Michalis Kamburelis
Ewald wrote: And what with non-blocking pipes pipes? Wait for a *some* period until you get all data? It is up to the programmer to do this INHO. If you want to get partial data (instead of waiting until all requested data is available) you should just use TStream.Read instead of TStream.Read

Re: [fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-15 Thread Ewald
On 16 Jun 2013, at 01:08, Michalis Kamburelis wrote: > > > Which means that ReadBuffer should retry calling Read, in a loop, trying to > finish the reading. ReadBuffer should raise an exception only when Read > returns zero (before we can gather all the Count bytes). > And what with non-blo

[fpc-pascal] TStream.ReadBuffer doesn't try hard enough to read the requested bytes

2013-06-15 Thread Michalis Kamburelis
Hi, I'm often reading fixed-size structures using TStream.ReadBuffer, working under the assumption that it will fail only if it's not possible to read the requested amount of bytes (that is, if the stream ended prematurely). This is actually the documented usage, see http://www.freepascal.org