Problem with Socket under Linux...
John M McIntosh
johnmci at mac.com
Wed Apr 24 21:55:08 UTC 2002
>Göran,
>
>> (Andreas, you must be in Germany right? Normally the list is
>> pretty dead when I am awake... :-))
>
>You're right ;-)
>
>> > > Then... you do not in fact signal the semaphore when there is
>> > > no data - right? (I don't really know what your last line before
>> > > "return 0" does, is that the "arming" stuff? Hey, btw, the Unix
>> > > version returns -1 if the socket is not valid, not 0...)
>> >
>> > Which is right. It means that the socket is broke, thus returning an
>> > error code (-1) instead of telling the client that there's simply no
>> > data available is the right thing to do.
>>
>> Good.
>
>Bad ... I just looked at the plugin side of it and it turns out that the
>code for receiveDataAvailable _cannot_ return an error code. The return
>code is converted into a boolean and any non-zero return value will be
>interpreted as "true". There ya go. Gotta check my own code now.
>
>Cheers,
> - Andreas
Beware of returning -1 from these calls. I think some older code once
returned -1 as the result of wanting to see how much data was
available. The Smalltalk code then said, oh, not zero, lets allocate
a new bytearray of -1 in length...
It's fuzzy to remember which call that was, but at the time it caused
of course a new primitive failure walkback.
--
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
===========================================================================
More information about the Squeak-dev
mailing list
|