1 -- Tests Copas with a simple Echo server
3 -- Run the test file and the connect to the server by telnet on the used port
4 -- to stop the test just send the command "quit"
6 local luaevent
= require("luaevent")
7 local socket
= require("socket")
14 local function echoHandler(skt
)
16 local data
,ret
= luaevent
.receive(skt
, 10)
17 --print("GOT: ", data, ret)
18 if data
== "quit" or ret
== 'closed' then
21 luaevent
.send(skt
, data
)
27 local server
= assert(socket
.bind("localhost", 20000))
29 local coro
= coroutine
.create
30 coroutine
.create
= function(...)
34 luaevent
.addserver(server
, echoHandler
)