Is this socket code correct?
Lex Spoon
lex at cc.gatech.edu
Thu Nov 18 21:23:07 UTC 1999
Could the socket possibly be closing? I think waitForDataUntil: should
return immediately when the socket closes. On Unix, even dataAvailable
will return true if the socket has closed, because the low-level API is
is very similar to waitForDataUntil:.
I just tried it on Linux, and indeed socket-closed and data-available
were the only obvious ways to make waitForDataUntil: return in your
example. (I imagine timing out would be a third way, but I didn't wait
for it to happen).
Maybe if you can give some more context, people could be more helpful.
In particular, are you trying to write a network app, or are you trying
to find weaknesses in Squeak or Linux's networking?
Lex
>
> I modified the code to read:
>
> [socket dataAvailable] whileFalse:
> [(socket waitForDataUntil: Socket standardDeadline) ifFalse:
> [self error: 'Timeout reading reply']].
> buffer _ ByteArray new: 10000.
> read _ socket receiveDataInto: buffer.
> read < 4
> ifTrue: [self error: 'Too few data read'].
>
> and I still get the 'Too few data read' error with read = 0.
>
> Any ideas?
>
> PS: I'm using 2.6 on linux
>
>
More information about the Squeak-dev
mailing list
|