Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
18
Task/Echo-server/LFE/echo-server.lfe
Normal file
18
Task/Echo-server/LFE/echo-server.lfe
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(defun start ()
|
||||
(spawn (lambda ()
|
||||
(let ((`#(ok ,socket) (gen_tcp:listen 12321 `(#(packet line)))))
|
||||
(echo-loop socket)))))
|
||||
|
||||
(defun echo-loop (socket)
|
||||
(let* ((`#(ok ,conn) (gen_tcp:accept socket))
|
||||
(handler (spawn (lambda () (handle conn)))))
|
||||
(lfe_io:format "Got connection: ~p~n" (list conn))
|
||||
(gen_tcp:controlling_process conn handler)
|
||||
(echo-loop socket)))
|
||||
|
||||
(defun handle (conn)
|
||||
(receive
|
||||
(`#(tcp ,conn ,data)
|
||||
(gen_tcp:send conn data))
|
||||
(`#(tcp_closed ,conn)
|
||||
(lfe_io:format "Connection closed: ~p~n" (list conn)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue