[Newbies] Read a filestream (named pipe) with a timeout
Ron Teitelbaum
ron at usmedrec.com
Thu Jan 9 21:16:25 UTC 2014
Hi Dave,
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,
Ron Teitelbaum
Head Of Engineering
3d Immersive Collaboration Consulting
ron at 3dicc.com
Follow Me On Twitter: @RonTeitelbaum
www.3dicc.com
https://www.google.com/+3dicc
> -----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
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.
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
More information about the Beginners
mailing list