Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
local uv = require 'couv'
local TEST_PORT = 9123
coroutine.wrap(function()
local handle = uv.Tcp.new()
handle:bind(uv.SockAddrV4.new('0.0.0.0', TEST_PORT))
handle:listen(128, function(server)
coroutine.wrap(function()
local stream = uv.Tcp.new()
server:accept(stream)
stream:startRead()
local nread, buf
repeat
nread, buf = stream:read()
if nread and nread > 0 then
local msg = buf:toString(1, nread)
if msg == 'QUIT' then
server:close()
break
end
stream:write({msg})
end
until nread and nread == 0
stream:stopRead()
stream:close()
end)()
end)
end)()
uv.run()