hy/eg/gevent/sockets/socket-server.hy

12 lines
267 B
Hy
Raw Normal View History

2013-03-28 01:09:42 +01:00
(import-from gevent.server StreamServer)
2013-03-28 01:52:06 +01:00
2013-03-28 01:09:42 +01:00
(defn handle [socket address]
(.send socket "Hello from Lisp!\n")
(for [x (range 5)] (.send socket (+ (str x) "\n")))
(.close socket))
(setv server (StreamServer (, "127.0.0.1" 5000) handle))
2013-03-28 01:09:42 +01:00
(.serve-forever server)