[Pharo-project] reading *exactly* n bytes from socket

Schwab,Wilhelm K bschwab at anest.ufl.edu
Mon Jan 16 05:19:47 CET 2012


I don't just write English, I also write Smalltalk :)  I had put some related code on SqueakMap, but I suspect it disappeared in one of the meltdowns.  It also picked up some code that I had not intended to release, which led me to be unhappy with http repositories.

The code varies in quality, covering things missing in streams, FFI, value adapters, among other things.  I recently noted that the FFI code will require tweaking to be of use with 1.3 and up.

Bill


________________________________________
From: pharo-project-bounces at lists.gforge.inria.fr [pharo-project-bounces at lists.gforge.inria.fr] on behalf of Stéphane Ducasse [stephane.ducasse at inria.fr]
Sent: Sunday, January 15, 2012 3:47 PM
To: Pharo-project at lists.gforge.inria.fr
Subject: Re: [Pharo-project] reading *exactly* n bytes from socket

On Jan 15, 2012, at 9:19 PM, Max Leske wrote:

> Good to know, that you're working on it. Took me a while to figure out that #next: would not fill the entiry buffer…

I'm not. I just know that bill tried to explain to us what was the problem :) and since the emails/sentences were too long or too english I was always lost but I know that there is this point that we should address.

>
> Unfortunately, I wasn't able to resolve my afore mentioned problem completely. To make things easier, I sent #upToEnd to my SocketStream, expecting to get all the data (and then read the lines later). However, towards the end of the transmission the connection is suddenly closed (ConnectionClosed is signaled by Socket>>waitForDataFor:) and I lose a variable amount of data (up to about 300KB out of 4.7MB). The primitive says that the server closed the connection (which might of course be true) but I can't see where my data went missing.
>
> In one case I even had a singel byte missing inside a line (the line was one byte shorter than advertised). Now this would probably be a totally different proplem and, to be fair, I couldn' reproduce it, so ignore this for now.
>
> Camillo is now looking into ithe SocketStream stuff but if any of you have a clue what could be going on, I'd appreciate your help.
>
> Cheers,
> Max
>
> On 15.01.2012, at 20:56, Stéphane Ducasse wrote:
>
>>
>> On Jan 15, 2012, at 8:10 PM, Schwab,Wilhelm K wrote:
>>
>>> 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
>>
>> Yes :)
>>
>> I know.
>>
>>>
>>> Bill
>>>
>>>
>>> ________________________________________
>>> From: pharo-project-bounces at lists.gforge.inria.fr [pharo-project-bounces at lists.gforge.inria.fr] on behalf of Max Leske [maxleske at gmail.com]
>>> Sent: Sunday, January 15, 2012 6:18 AM
>>> To: pharo-project at lists.gforge.inria.fr
>>> 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
>>>
>>>
>>>
>>
>>
>
>





More information about the Pharo-project mailing list