Thread: Help on LISP please?

  1. #1
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Cambridge, UK

    Help on LISP please?

    Hi, I am a newbi for Lisp programming. But i got finish of this project which i am doing. I need your help please.

    I have server which is written on LISP. The server itself works fine. The problem which I have is if my client sends a string data to the server. The server can read just one char. That is when i use read or read-line functions. There is no effect at all on passive sockets. Here is a snap of my code which I am facing problem with:

    (defun RouteServer (&key (port 9259)) 
      (let ((p (socket:make-socket :connect :passive 
                                   :local-port port 
                                   :reuse-address t))) 
        ;; Accept the connections here 
          (let ((s (socket:accept-connection p))) 
            ;; Read the char from the client 
            (setf R (read-char s)) 
            ;; If i use read here it donst even read anything from the stream. 
            ;;(setq R (read s))      
            ;; Switch statment to check, which function need 
            ;; to be executed. 
            ;; 1 - Robert problem 
            ;; 2 - MAZE problem 
            ;; 3 - Stops the server (But the port is not closed yet) 
            (cond ((eq R #\1) (format s "~s|" (callops)) 
                   (format s "Error: Invalid function call")) 
                  ((eq R #\2) (format s "~s|" (callMAZE)) 
                   (format s "Error: Invalid function call")) 
                  ((eq R #\3) #'(lambda () (close s)(close p))(return))) 
            (close s)))))
    Thanks a lot


  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Plano, Texas, United States
    Well, I must admit that I am not a LISP expert, but I will try and take a crack at this. My knowledge of LISP really only comes from about 4 months of Scheme usage last year.


    Here is a page that I found particularly useful:

    LISP input functions

    I think it would be valuable to know exactly what input your program is expected to receive? I noticed that functions like read will only read string representations of valid LISP objects, such as "(1 2 3)" becomes (1 2 3) when it is read.

    read-line on the other hand will input strings from the input stream, and then return them as a string object. I doubt, however, that you can then just treat it as a character object if that's what you are wanting to do.

    You could also try using the listen function to see if there is anything actually in the input stream to read. Have you tried checking your inputs? a.k.a - immediately output to the screen what you just inputted.

    Eh...I can't say much more than that. Like I said, I am no LISP expert.
    My Website

    "Circular logic is good because it is."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with with Lisp Reader Technique
    By tuxinator in forum C Programming
    Replies: 15
    Last Post: 05-07-2006, 05:30 PM
  2. LISP (DrScheme) any one?
    By Jeremy G in forum A Brief History of
    Replies: 5
    Last Post: 03-31-2004, 12:52 PM
  3. Lisp
    By Silvercord in forum A Brief History of
    Replies: 4
    Last Post: 08-26-2003, 12:41 PM
  4. IDEA: LISP Interpreter
    By ygfperson in forum Contests Board
    Replies: 4
    Last Post: 09-13-2002, 08:48 PM
  5. Lisp
    By Lechugas in forum A Brief History of
    Replies: 2
    Last Post: 01-18-2002, 12:21 PM