[Squeak 3.9] Socket waitForData won't wake up when data become available

goran at krampe.se goran at krampe.se
Tue Jun 12 08:01:58 UTC 2007


Niko Schwarz <niko.schwarz at gmx.net> wrote:
> 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!

Ok, could this simply be due to Process scheduling? Is this fork getting

Because reading my code (I wrote this version of SocketStream) I can't
for my life figure out how it could block AND get data into the inbuffer

Btw, I noticed in 3.8.1 the #buffered: and #buffered methods. They do
not belong there - I have no idea why they are there or why they are
empty. In FastSocketStream (on SM), which is the original implementation
of this newish SocketStream class there are no such methods.

regards, Göran

More information about the Squeak-dev mailing list