On 29 January 2010 23:09, stephane ducasse <[email protected]> wrote:
> hi Igor
>
> finally should I integrate
>        http://bugs.squeak.org/view.php?id=7446 ?
> I was waiting because you said you were confused
>

Yes, integrate that, since it deals with issue that #peek should
answer the same byte as following #next.

We turned discussion into other issues, not related to this _bug_ (but
related to #peek behavior), concerning what will happen if timeout
appear. Here the last version(s) of both peek and next which taking
care about it:


!SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 02:02'!
next
        "Return next byte, if inBuffer is empty
        we recieve some more data and try again."

        [self isDataAvailable] whileFalse: [
                self receiveData. self atEnd ifTrue: [ ^ nil ]].
        
        ^inBuffer at: (lastRead := lastRead + 1)
! !

!SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 01:33'!
peek
        "Return next byte, if inBuffer is empty
        we recieve some more data and try again.
        Do not consume the byte."

        [self isDataAvailable] whileFalse: [
                self receiveData. self atEnd ifTrue: [ ^ nil ]].
        
        ^inBuffer at: lastRead +1! !


As you can see, the only difference between peek and next is that one
advancing the buffer pointer, while other not.

> Stef
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



-- 
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to