Is there a non-blocking version of hGetArray?

Simon Marlow simonmar at
Tue Oct 5 06:32:56 EDT 2004

On 02 October 2004 13:04, Tomasz Zielonka wrote:

> On Fri, Oct 01, 2004 at 09:34:36PM +0100, Simon Marlow wrote:
>> Not currently, but I could probably implement the equivalent
>> (hGetArrayNonBlocking).
> It is perhaps not closely related, but could we also have
> Network.Socket recvFrom / sendTo working on raw buffers?
> I've attached a proposed implementation. It moves most of code to
> recvBufFrom and sendBufTo, and changes recvFrom / sendTo to use the
> *Buf* functions.

Committed, thanks!
> It would be nice if these functions could be used to implement
> efficient recvFromArray / sendToArray (without copying), but I don't
> know if it's possible to get the pointer from MutableByteArray. Is
> there a danger that GC invalidates the pointer?

It is possible to get a Ptr from a MutableByteArray, but only if the
array was allocated pinned, and only if you make sure it lives across
any foreign calls (using touch#).  This is how Foreign.alloca works, for


More information about the Glasgow-haskell-users mailing list