[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MIT-Scheme-users] Simple Client/Server
From: |
Matt Birkholz |
Subject: |
Re: [MIT-Scheme-users] Simple Client/Server |
Date: |
Mon, 27 Apr 2009 20:04:41 -0700 |
> From: Taylor R Campbell <address@hidden>
> Date: Mon, 27 Apr 2009 19:41:34 -0400
>
> [...]
>
> Nevertheless, as you suggest, it is good practice to close the
> socket explicitly.
So something like this would be more in order:
(define (start-server service)
(let ((server-sock (open-tcp-server-socket service)))
(display "Server ready to accept connections.")(newline)
(let* ((port (tcp-server-connection-accept server-sock #t #f))
(from-client (read-line port)))
(display from-client port)(newline port)
(display from-client)(newline)
(close-port port))
(close-tcp-server-socket server-sock)))
The above procedure echoes the line to the client AND the console.