picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

chat (530B)


      1 #!bin/picolisp lib.l
      2 # 21dec05abu
      3 
      4 # *Port *Sock *Name
      5 
      6 (de chat Lst
      7    (out *Sock
      8       (mapc prin Lst)
      9       (prinl) ) )
     10 
     11 
     12 (setq *Port (port 4004))
     13 
     14 (loop
     15    (setq *Sock (listen *Port))
     16    (NIL (fork) (close *Port))
     17    (close *Sock) )
     18 
     19 (out *Sock
     20    (prin "Please enter your name: ")
     21    (flush) )
     22 (in *Sock (setq *Name (line T)))
     23 
     24 (tell 'chat "+++ " *Name " arrived +++")
     25 
     26 (task *Sock
     27    (in @
     28       (ifn (eof)
     29          (tell 'chat *Name "> " (line T))
     30          (tell 'chat "--- " *Name " left ---")
     31          (bye) ) ) )
     32 (wait)