write operation timed out added by mario-goulart on Thu Mar 8 14:12:14 2012

;; Server

(use tcp srfi-18)

(let ((listener (tcp-listen 4321)))
  (let accept-next-connection ()
    (receive (in out)
      (tcp-accept listener)
      (thread-start!
       (lambda ()
	 (let loop ()
	   (display "this text has more than 4 chars" out)
	   (flush-output out)
	   (loop)))))
    (accept-next-connection)))



;; Client

(use tcp posix srfi-18)

(let-values (((in out) (tcp-connect "localhost" 4321)))
  (thread-start!
   (lambda ()
     (let loop ()
       (thread-wait-for-i/o! (port->fileno in) #:input)
       (let ((response (read-string 4 in)))
	 (print "response: " response)
	 (thread-sleep! 1)
	 (loop)))))
  (thread-join! (thread-start!
		 (lambda ()
		   (let loop ()
		     (print "----")
		     (thread-sleep! 1)
		     (loop))))))