Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - chylli

#1
newLISP in the real world /
February 20, 2009, 05:26:32 AM
thanks for your reply. then the net-select still didn't support file descriptor ?
#2
I want to read from stdin and a socket, but it is tedious and urgly to do so like

(while 1 (if (peek 0) ....) (if (net-peek socket) ...) (sleep 10))



I think there is an select function in linux, man 2 select. is there way to do that in newlisp ?
#3
newLISP newS /
February 19, 2009, 10:18:52 PM
it will be greate if there is a place like cpan.
#4
Anything else we might add? /
February 19, 2009, 07:17:17 PM
my program exit early only when I use add_history function on libhistory. so I think I misused it ?



(while (net-recieve) ... is ok when I don't use add_history.  and it is a simplified version. I will change it when I resovled this problem.





thanks!
#5
hi, I'm a newbie of newlisp. now I writed one very simple mud client as following.



now it has two problem:

1. if I use readline search function, the program will exit silently. I think it is about memory problem.  can anyone fix it ???



2. when the peer of socket close the connection, the program will exit. but I must enter an "n" before the console returned to shell. why ?



thanks.



this is the probram:





#!/usr/bin/newlisp

;; server

(define mud-server '("pkuxkx.3322.org" 8081))



(context 'greadline)

(import "libhistory.so.5" "add_history")

(import "libreadline.so.5" "readline")

(define (greadline:greadline)

  (set 'getted-string-p (readline ""))

  (add_history getted-string-p)

  (get-string getted-string-p))



(context MAIN)



(set 'server (apply net-connect mud-server))



(fork (begin

        (while (net-receive server buffer 8192)

               (print buffer))

        (letn ((error (net-error))

               (error-code (error 0)))

          (if (= error-code 6)

              (println "bye bye!!")

              (print (error 1))))))



(constant 'SIGCHLD 17)

(define (sig_chld_handler)

  (wait-pid -1 nil)

  (close server)

  (exit))



(signal SIGCHLD sig_chld_handler)

 

(while 1 (net-send server (append (greadline) "rn")))





(exit)