If the client (host B) is MacOSX 10.4 the second call to (do-call) fails.
-------------------
;;;
;;;; --
;;;; simple server
;;;
; Run this on host A
(define (server-start)
(let ((command-queue (open-tcp-server
(list port-number: 5000
reuse-address: #t
eol-encoding: 'cr))))
(let loop ()
(let ((incoming-connection (read command-queue)))
(display "Got connection\n")
(serve-command incoming-connection))
(loop))))
(define (serve-command incoming-connection)
(let* ((parsed-command (read incoming-connection)))
(display (list "received command" parsed-command))
(if parsed-command
(write "toto" incoming-connection))
(close-port incoming-connection)))
(thread-start! (make-thread (lambda ()
(server-start))))
-------------------
;;;
;;;; --
;;;; simple client
;;;
; run this on host B
(define Host-A-IP "206.167.88.52")
(define (do-call sleep?)
(let* ((connection (open-tcp-client (list server-address: Host-A-IP ; put Host A IP here
port-number: 5000
eol-encoding: 'cr))))
(if sleep?
(thread-sleep! 1))
(write (list 1 2 3) connection)
(display "\n" connection)
(force-output connection)
(let ((result (read connection)))
(close-port connection)
result)))
(define (test)
(thread-sleep! 1)
(display "try with sleeping...\n")
(do-call #t)
(display "sleeping...\n")
(force-output)
(thread-sleep! 1)
(display "now try without sleeping...\n")
(do-call #f))
;(##repl)
(test)
; Fails on MacOSX 10.4
; Works on Windows XP (MinGW)
-------------------