Ticket #614: listen.scm
File listen.scm, 575 bytes (added by , 13 years ago) |
---|
Line | |
---|---|
1 | (use tcp srfi-18 posix srfi-1) |
2 | |
3 | (define listener (tcp-listen 8080)) |
4 | |
5 | (let loop () |
6 | (receive (in out) (tcp-accept listener) |
7 | (thread-start! |
8 | (lambda () |
9 | (let ((x (read-string 10 in))) |
10 | ;; (thread-sleep! 2) |
11 | (print (current-seconds)) |
12 | (display x out) |
13 | (flush-output out) |
14 | |
15 | (let ((no (##sys#tcp-port->fileno in))) |
16 | (close-input-port in) |
17 | (close-output-port out) |
18 | (fprintf (current-error-port) "~A ~A~%" |
19 | (thread-name (current-thread)) |
20 | no)))))) |
21 | (loop)) |