[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads

From: Manuel Giraud
Subject: Re: Threads
Date: 25 Sep 2001 09:51:34 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

"Jorgen 'forcer' Schaefer" <address@hidden> writes:

> Manuel Giraud <address@hidden> writes:
> > (begin-thread
> >   (let loop ()
> >     (display "My endless treatment\n")
> >     (sleep 5)))
> > 
> > But this thread is just active for one display and stops.
> You're not looping :)
> Add a call to (loop) after the sleep...

It was just a typo, here is an example of my server and client : 

;;; Server loop
(let loop ()
  ;; Waiting for some message.
  (let* ((pair (accept sock))
         (sock (car pair))
         (conn (cdr pair))
         (rcv (read sock)))

    ;; A new thread that will endlessly evaluate the received
    ;; expression.
     (let looping ()
       (eval rcv)
       (sleep 5)

  ;; Back to waiting.

;;; Client
;;; The message : a s-expression.
(define message '(display "hello\n"))

;;; Connect and send
(connect sock AF_INET (car (hostent:addr-list (gethost sname))) port)
(write message sock)

With the begin-thread, I can't see any "hello" but it works without. I
have to say that a standalone example like : 

 (let loop ()
   (display "hello\n")
   (sleep 1)

works well. So what's wrong ?

"Never imagine yourself not to be otherwise than what it might appear
to others that what you were or might have been was not otherwise than
what you had been would have appeared to them to be otherwise"
  The Duchess

_Manuel Giraud_

reply via email to

[Prev in Thread] Current Thread [Next in Thread]