For a project I've just been working on, I needed to be able to transfer in a socket that I created outside of uWebSockets/uSockets. I modified loop.c by moving the guts of the accept loop into a new function (us_socket_transfer) which is externally callable. The contents of the accept loop becomes just a call to this function, but if I create an accepted socket elsewhere in my program (transferred from another process, in my case) then I can call this function and the uWS::Loop "adopts" it. I haven't done extensive testing yet (and my code is just for an internal prototype so its not likely to become production code), but it seems to be working well. I thought I would suggest the change in case others might find it useful (I saw one issue mentioning inter-process socket transfers).
For a project I've just been working on, I needed to be able to transfer in a socket that I created outside of uWebSockets/uSockets. I modified loop.c by moving the guts of the accept loop into a new function (
us_socket_transfer
) which is externally callable. The contents of the accept loop becomes just a call to this function, but if I create an accepted socket elsewhere in my program (transferred from another process, in my case) then I can call this function and the uWS::Loop "adopts" it. I haven't done extensive testing yet (and my code is just for an internal prototype so its not likely to become production code), but it seems to be working well. I thought I would suggest the change in case others might find it useful (I saw one issue mentioning inter-process socket transfers).