Open
Description
Hi, I'm trying to send handles over pipes. I've created a socketpair and sent one end to a new thread and when I try to read/write between them, it just works. 6328 In the following code though, I'm sending accepted TCP connections to a thread via write2 but it doesn't work.
local uv = require "luv"
local fds = uv.socketpair(nil, nil, { nonblock = true }, { nonblock = true })
-- setup worker thread
uv.new_thread(function(fd)
local uv = require "luv"
local pipe = uv.new_pipe(false)
pipe:open(fd)
pipe:listen(128, function()
local client = uv.new_tcp()
pipe:accept(client)
print "handle received by worker"
client:close()
end)
uv.run()
end, fds[2])
-- setup writer pipe & tcp server
local pipe = uv.new_pipe(true)
pipe:open(fds[1])
local server = uv.new_tcp()
server:bind("127.0.0.1", 3000)
server:listen(128, function()
local client = uv.new_tcp()
server:accept(client)
-- send it to worker thread
pipe:write2("", client)
end)
uv.run()
Metadata
Metadata
Assignees
Labels
No labels