8000 Unable to send handles with uv_write2 · Issue #692 · luvit/luv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Unable to send handles with uv_write2 #692
Open
@nikneym

Description

@nikneym

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0