[Newbies] Read a filestream (named pipe) with a timeout

dsl101 dl3 at pale-eds.co.uk
Thu Jan 9 15:16:23 UTC 2014


I'm using Squeak 4.2 and working on the smalltalk end of a named pipe
connection, which sends a message to the named pipe server with:

	msg := 'Here''s Johnny!!!!'.
	pipe nextPutAll: msg; flush.

It should then receive an acknowledgement, which will be a 32-byte md5 hash
of the received message (which the smalltalk app can then verify). It's
possible the named pipe server may have gone away or otherwise been unable
to deal with the request, and so I'd like to set a timeout on reading the
acknowledgement. I've tried using this:

	ack := [ pipe next: 32 ] valueWithin: (Duration seconds: 3) onTimeout: [
'timeout'. ].

and then made the pipe server pause artificially to test the code. But the
smalltalk thread blocks on the read and doesn't carry on (even after the
timeout), although if I then get the pipe server to send the correct
response (after a 5 second delay, for example), the value of 'ack' is
'timeout'. Obviously the timeout did what it's supposed to do, but couldn't
'unblock' the blocking read on the pipe.

Is there a way to accomplish this even with a blocking FileStream read? I'd
rather avoid a busy wait on there being 32 characters available if at all
possible.

Thanks,

Dave



--
View this message in context: http://forum.world.st/Read-a-filestream-named-pipe-with-a-timeout-tp4735456.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.


More information about the Beginners mailing list