[plt-scheme] run-server

From: Paulo J. Matos (pocm at mega.ist.utl.pt)
Date: Wed Oct 2 13:15:46 EDT 2002

Hi all,

I'm doing an echo server just to get friendly with run-server but
not even that I'm being able to do. Here's the code:
server:
(require (lib "thread.ss"))

(define echo-port 23421)

(define echo-server 
  (lambda (inputport outputport)
    (printf "Going to get char...~n")
    (let ((val (read-line inputport)))
      (printf "Received: ~a~n" val)
      (write val outputport))))

(run-server echo-port echo-server #f)

client:
(define hostname "localhost")
(define echo-port 23421)

(define echo
  (lambda (inputport outputport)
    (printf "Iteration~n")
    (write (read-line) outputport)
    (printf "Waiting for char...~n")
    (wait-char inputport)
    (display (read-line inputport))
    (echo inputport outputport)))

(define wait-char
  (lambda (port)
    (let recur ()
      (if (not (char-ready? port))
          (recur)))))
          
(define ip null)
(define op null)

(set!-values (ip op)
             (tcp-connect hostname echo-port))

(echo ip op)


Ok, as you can see I can't send anything, I don't know if I'm not
sending it correctly or receiving it correctly. Also, my
wait-char, is not very good. How can I make it sleep until it
receives something?

Best regards,
-- 
Paulo J. Matos : pocm(_at_)mega.ist.utl.pt
Instituto Superior Tecnico - Lisbon    
Software & Computer Engineering - A.I.
 - > http://mega.ist.utl.pt/~pocm 
 ---	
	Yes, God had a deadline...
		So, He wrote it all in Lisp!



Posted on the users mailing list.