Subject: [clisp-list] Re: FFI - Creating c-places in LISP? -> READ-SOME-SEQUENCE

From: Bruno Haible <[email-masked]>
Date: Wed Oct 2 17:09:29 2002

Joerg wrote:
> I believe non-blocking is not needed if preceeded by select(). Would
> you like to comment?

select() does not tell you how many bytes of input you can read, or
how many bytes you can write, without blocking. Thus if you want to
avoid blocking, you have to read() or write() the bytes one by one,
which damages performance if there is not a computation intensive
counterpart on the Lisp side.

Therefore most Unices offer the ability to put a socket or file
descriptor into non-blocking mode.

Bruno

---

From: Sam Steingold <[email-masked]>
Date: Fri Oct 4 06:33:02 2002

We already have READ-CHAR-NO-HANG and READ-BYTE-NO-HANG, so, I think,
READ-SEQUENCE-NO-HANG is the right name, if we really need it.

> * In message <[email-masked]>
> * On the subject of "Re: FFI - Creating c-places in LISP? -> READ-SOME-SEQUENCE"
> * Sent on Thu, 3 Oct 2002 02:04:14 +0200 (CEST)
> * Honorable Bruno Haible <[email-masked]> writes:
>

So why not add FIONBIO to SOCKET-OPTIONS and let the users call that
before READ-SEQUENCE?

(Arseny said that FIONBIO will break some things - which ones?)

Alternatively, READ-SEQUENCE-NO-HANG may just put the socket into
non-blocking mode before the actual input call and then put it back
into the blocking mode.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Our business is run on trust.  We trust you will pay in advance.

---

From: Arseny Slobodjuck <[email-masked]>
Date: Fri Oct 4 15:28:03 2002

Hello Sam,

> (Arseny said that FIONBIO will break some things - which ones?)

At least you should then check for [WSA]EWOULDBLOCK error in all reads
and writes. send() also can return less than data length supplied.
Maybe there is something else, need to look into the code. I'm just
saying it's not enough just to put a socket in nonblocking mode - need
to check all the code to handle it (FIXME).

Next, to get rid of WSACancelBlockingCall I wanted to make all sockets
nonblocking and emulate blocking with select() loops. It is possible
(FIXME).

So maybe make a socket-stream option BLOCKING and use it in that
select loops and in READ-SEQUENCE ?

Advantages:
1. can be queried (AFAIK blocking mode of socket can't be checked)
  so READ-SEQUENCE can determine how to behave.
2. Lowlevel code handling just one socket mode, simpler.
3. no WSACancelBlockingCall.

-- 
Best regards,
 Arseny

---

From: Sam Steingold <[email-masked]>
Date: Tue Oct 8 18:37:01 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] Re: READ-SEQUENCE-NO-HANG"
> * Sent on Sat, 5 Oct 2002 09:26:46 +1000
> * Honorable Arseny Slobodjuck <[email-masked]> writes:
>

why not do it "implicitly"?

add READ/WRITE-CHAR/BYTE-SEQUENCE-NO-HANG (that's 4 functions)
which, on entry, put the socket (if that was a socket stream)
into a non-blocking mode and do the I/O;
before the return, you will need to put the socket back into blocking
mode (see make_HANDLER_frame/unwind_HANDLER_frame).

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Marriage is the sole cause of divorce.