手册: http://wiki.call-cc.org/man/4/Unit%20tcp
示例代码
; client.scm
(declare (uses tcp))
(define l (tcp-listen 4242))
(define-values (i o) (tcp-accept l))
(write-line "Hello!" o)
(print (read-line i))
(close-input-port i)
(close-output-port o)
; server.scm
(declare (uses tcp))
(define l (tcp-listen 4242))
(define-values (i o) (tcp-accept l))
(write-line "Hello!" o)
(print (read-line i))
(close-input-port i)
(close-output-port o)
% csc server.scm
% csc client.scm
% ./server &
% ./client
可,结果呢……
Error: segmentation violation
Call history:
server.scm:2: tcp-listen
server.scm:3: ##sys#call-with-values
server.scm:3: tcp-accept <--
Error: segmentation violation
Call history:
client.scm:2: ##sys#call-with-values
client.scm:2: tcp-connect <--
[1]+ Exit 70 ./server
(未完)