[iolib-devel] Bug when using READ-LINE on non-blocking fds
mm_lists at pulsar-zone.net
Sun Feb 8 07:16:28 UTC 2009
On Sun, 08 Feb 2009 01:59:56 +0530
Chaitanya Gupta <mail at chaitanyagupta.com> wrote:
> On that note, does iolib provide any function to read a chunk of data
> without blocking i.e. something like READ-CHAR-NO-HANG for sequences?
> (or, something akin to what read(2) provides when O_NONBLOCK is set).
It is possible to use RECEIVE-FROM which would signal
IOLIB.SYSCALLS:EWOULDBLOCK if the socket is non-blocking and no
remaining data is ready to read, or IOLIB.SYSCALLS:EINTR on reception
of a signal, but I'm not sure if this could work with buffering, or if
it would conflict with stream operations (i.e. in C you wouldn't use
stdio fread()/fgets() and read() concurrently).
I've used RECEIVE-FROM without issues when creating sockets with 0
bytes receive and send buffers and using custom buffers.
An example may be found at
(Note that READ-LINE-FROM-QUEUE and WRITE-STRING-TO-QUEUE are
SBCL-specific as they use SB-EXT to convert between UTF-8 strings and
8-bit bytes representations).
More information about the iolib-devel