mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Initial example
This commit is contained in:
parent
929412a29b
commit
2b115c989d
1 changed files with 20 additions and 0 deletions
20
examples/networking/http-server.scm
Normal file
20
examples/networking/http-server.scm
Normal file
|
@ -0,0 +1,20 @@
|
|||
(import
|
||||
(scheme base)
|
||||
(scheme write)
|
||||
; (srfi 18)
|
||||
(srfi 106))
|
||||
|
||||
(define *port* "8080")
|
||||
(define svr (make-server-socket *port*))
|
||||
|
||||
(let* ((s (socket-accept svr))
|
||||
(data (socket-recv s 2048)))
|
||||
(display `("received: " ,(utf8->string data)))
|
||||
(newline)
|
||||
(socket-send s
|
||||
(string->utf8
|
||||
"HTTP/1.1 200 OK\nContent-Type: text/plain\nContent-Length: 12\n\nHello world!"))
|
||||
(socket-close s))
|
||||
|
||||
(socket-close svr)
|
||||
|
Loading…
Add table
Reference in a new issue