[Pharo-project] reading *exactly* n bytes from socket
maxleske at gmail.com
Sun Jan 15 12:09:17 CET 2012
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?
More information about the Pharo-project