[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] non-blocking (read)
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] non-blocking (read) |
Date: |
Tue, 19 Jul 2005 10:07:23 +0200 |
On 7/19/05, Daishi Kato <address@hidden> wrote:
> For example, an application would be a server program
> that is controlable by a user through some kind of commands.
> In other words, a server program with CUI.
> Currently I could do it by csi, since it does not block the server thread,
> but what if I would like to compile it into a single executable?
> Would char-ready? help?
>
How do you communicate with the sever? If it's a sub-process,
you can use `process' (posix unit) which is non-blocking:
% cat slow.sh
#!/bin/sh
echo "hello!"
sleep 1
echo "yes"
sleep 3
echo "no"
% cat listen.scm
;;;; listen.scm
(use posix srfi-18)
(thread-start!
(lambda ()
(let loop ((i 1))
(thread-sleep! 0.5)
(print "[" i "]")
(loop (add1 i)) ) ) )
(define-values (i o _) (process "./slow.sh"))
(port-for-each print (cut read-line i)) ; assumes Chicken 2.0, a
simple loop works as well
(close-input-port i)
(close-output-port o)
% csi -script listen.scm
...
cheers,
felix
- [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/15
- Re: [Chicken-users] non-blocking (read), felix winkelmann, 2005/07/17
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/18
- Re: [Chicken-users] non-blocking (read),
felix winkelmann <=
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/19
- Re: [Chicken-users] non-blocking (read), Thomas Chust, 2005/07/19
- Re: [Chicken-users] non-blocking (read), felix winkelmann, 2005/07/20
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/20
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/20