[Squeak 3.9] Socket waitForData won't wake up when data become
available
Niko Schwarz
niko.schwarz at gmx.net
Mon Jun 11 23:00:45 UTC 2007
Hello!
I was playing a little with the JDBC bridge, which is a TCP server on
the loopback device, modifying it slightly. I discovered some strange
behaviour on the way.
I'm controlling the tcp server by sending him commands through the
loopback device. When you first connect to the server, it won't
answer immediately, it rather waits for a set of commands first. So,
I'm connecting to the server:
addr := NetNameResolver addressForName: 'localhost'.
socket := Socket newTCP connectTo: addr port: 1446.
stream := (SocketStream on: socket) timeout: 0
Now the two notice each, but nothing is sent in any direction except
for the tcp handshake packages.
now, im installing my listener thread:
[stream next] fork
which blocks as expected, as I'm observing it in the process browser.
Now, i send the commands to the server, making it respond, through my
private method sendThrough. the sent commands provably arrive at the
server and do make it respond (the response actually arrives in the
socketStreams inbuffer!)
'one' sendThrough: stream. 'two' sendThrough: stream . 'three'
sendThrough: stream.
inspecting the stream reveals that the data has arrived and landed in
the buffer, but a look into the process browser shows that the frozen
process waiting for data won't wake up!
even if you alter the example by using
[socket waitForData] fork
as reading thread, it won't wake up.
It doesn't help either to set the SocketStream with a timeout greater
than 0. if i do that, it times out after 45 seconds, eventhough data
are available.
Now, this is relatively annoying to me. Of course I could restructure
the code to only read the socket when there are most probably data to
be received; but that would be less reliable and certainly uglier
than my reading process.
so, does anyone have a clue what I'm doing wrong?
thanks in advance,
Niko
More information about the Squeak-dev
mailing list
|