Ticket #614: client.scm

File client.scm, 564 bytes (added by Moritz Heidkamp, 15 years ago)
Line 
1(use srfi-18 tcp)
2
3(define data (make-string 10))
4
5(define threads
6 (let loop ((i 0))
7 (if (= 1000 i)
8 '()
9 (cons
10 (thread-start!
11 (lambda ()
12 (receive (in out) (tcp-connect "localhost" 8080)
13 (display data out)
14 (flush-output out)
15 (read-string 10 in)
16 (close-output-port out)
17 (close-input-port in))))
18 (loop (+ i 1))))))
19
20
21
22(let loop ((threads threads))
23 (unless (null? threads)
24 (thread-join! (car threads))
25 (loop (cdr threads))))