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"
8 local function echoHandler(skt
)
10 local data
,ret
= luaevent
.receive(skt
, 10)
11 if data
== "quit" or ret
== 'closed' or not data
then
15 if not luaevent
.send(skt
, data
) then return end
17 if skt
then skt
:close() end
20 local server
= assert(socket
.bind("localhost", 20000))
23 luaevent
.addserver(server
, echoHandler
)