[Newbies] Read a filestream (named pipe) with a timeout
ron at usmedrec.com
Thu Jan 9 21:16:25 UTC 2014
See #dataAvailable and #recieveAvailableData.
It's never good to call for data if you don't know you have any. Better to
setup a wait for data until call instead.
All the best,
Head Of Engineering
3d Immersive Collaboration Consulting
ron at 3dicc.com
Follow Me On Twitter: @RonTeitelbaum
> -----Original Message-----
> From: beginners-bounces at lists.squeakfoundation.org [mailto:beginners-
> bounces at lists.squeakfoundation.org] On Behalf Of dsl101
> Sent: Thursday, January 09, 2014 10:16 AM
> To: beginners at lists.squeakfoundation.org
> Subject: [Newbies] Read a filestream (named pipe) with a timeout
> 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
> the received message (which the smalltalk app can then verify). It's
> 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
> I've tried using this:
> ack := [ pipe next: 32 ] valueWithin: (Duration seconds: 3)
> '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
> (after a 5 second delay, for example), the value of 'ack' is 'timeout'.
> the timeout did what it's supposed to do, but couldn't 'unblock' the
> read on the pipe.
> Is there a way to accomplish this even with a blocking FileStream read?
> avoid a busy wait on there being 32 characters available if at all
> View this message in context:
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners