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