On Tue, Oct 10, 2017 at 1:38 PM, Alexey Plotnik <plotnik.ale...@gmail.com> wrote: > There are few techniques can be used to balanceTCP connections across event > loops: https://github.com/libuv/libuv/issues/932#issuecomment-229884507. > > One can just use SO_REUSEPORT on modern kernels. Or accept hanlde in one > loop, then send it with uv_write2 to another loop over IPC pipe, for > example. > > By the way, the last one works perfectly. > > How about UDP? There is no idea of connection, but frames only, so what is > the recommended way to "balance" some part of UDP "stream" across threads? > > uv_write2 does not support upd handles: > >> end_handle must be a TCP socket or pipe > > > My question: is there a way to balance/"emulate balancing"/etc UDP handles. > Is there a way to move UDP handles to another loop? > > Maybe is there more elegant way to do that? > > Thanks!
uv_write2() can be used to send over UDP handles if you don't care about Windows. The handle address, somewhat illogically, needs to be casted to uv_stream_t but libuv only looks at the uv_handle_t fields. Note that if you want maximum performance, libuv's non-blocking, event-driven approach won't be able to compete with simple blocking reads, due to the fact that it needs to make more system calls: one to get notified there is data to read, a second one to read it. -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to libuv+unsubscr...@googlegroups.com. To post to this group, send email to libuv@googlegroups.com. Visit this group at https://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.