Max,
I wouldn't forget it too soon. Streams should work as advertised or raise an
error. My (compromise) proposal remains as follows:
http://code.google.com/p/pharo/wiki/StreamsForRobustSoftware
Bill
________________________________________
From: [email protected]
[[email protected]] on behalf of Max Leske
[[email protected]]
Sent: Sunday, January 15, 2012 6:18 AM
To: [email protected]
Subject: Re: [Pharo-project] reading *exactly* n bytes from socket
Sorry, forget what I just wrote…
I found the bug in my code. Should have checked if the connection is still open
:-/
Cheers,
Max
On 15.01.2012, at 12:09, Max Leske wrote:
> Hey guys
>
> I'm having a problem with Socket / SocketStream. When I know that the next
> packet of data from the server is going to be 10'000 bytes I want to ask the
> socket for exactly 10'000 bytes of data (I don't care how long it takes).
> However, the comments in the Socket class suggest that the buffer might not
> be filled entirely when the message answers. As a consequence, my code fails
> because the ByteArray sometimes has a number of zero bytes at the end which
> obviously wasn't expected.
> I also tried to use SocketStream to get around this problem but wasn't
> successful. Am I supposed to handle this case myself or did I overlook
> something?
>
> Cheers,
> Max