[squeak-dev] Re: SocketStream>>atEnd

Igor Stasenko siguctua at gmail.com
Thu Jan 14 23:38:22 UTC 2010


It appears that im wrong. sorry for disturbing :)

2010/1/15 Igor Stasenko <siguctua at gmail.com>:
> Hello guys,
>
> today, by examining closely the #atEnd implementation , i came to
> conclision that is can be made as simple as:
>
> atEnd
>  ^ self isDataAvailable not
>
>
> Because, take a close look at old implementation:
> atEnd
>        self isInBufferEmpty ifFalse: [^false].   ----***---
>        ^self isConnected not
>                and: [self isDataAvailable not]
>
> and:
> isDataAvailable
>
>        self isInBufferEmpty ifFalse: [^true].  ---***---
>        ^socket dataAvailable
>                ifFalse: [false]
>                ifTrue: [self receiveDataIfAvailable; isDataAvailable]
>
>
> a Socket>>dataAvailable answers false on closed or invalid socket. You
> can check it quite simply:
>
> (SocketStream openConnectionToHostNamed:  'google.com' port: 80)
> socket closeAndDestroy dataAvailable
> (SocketStream openConnectionToHostNamed:  'google.com' port: 80) close
> socket dataAvailable
> Socket new dataAvailable
> => all 3 answer false
>
> Therefore, a complex logic in #atEnd, could be simplified.
>
> Please, try to find a flaw in my conclusions. I think there's not. But
> 2 (or more) heads always better than 1.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list