uSockets icon indicating copy to clipboard operation
uSockets copied to clipboard

us_socket_transfer

Open abrownsword opened this issue 3 years ago • 4 comments
trafficstars

Add new function us_socket_transfer by extracting existing code for handling accepted sockets, and calling it from its former location. The new function can now be used to hand off a newly connected socket from outside the framework into the framework.

abrownsword avatar Apr 05 '22 23:04 abrownsword

I might use this too

Jarred-Sumner avatar Apr 11 '22 08:04 Jarred-Sumner

The idea is more to use a common event loop across all libraries you use, than to manually deal with FD. For instance if you do Asio there is a compilation flag for using Asio under uSockets

ghost avatar Apr 11 '22 15:04 ghost

Yes, but sometimes you are just going to have a file descriptor you want that common event loop to use. The OS and most other code deals in file descriptors, so there ought to be a way to introduce an externally created descriptor to enable interop with uWS. In my case I needed to send an accepted socket from another process, but there may be other such use cases.

abrownsword avatar Apr 11 '22 15:04 abrownsword

This is going to get merged from Bun (where you also have attach/release) in a while.

uNetworkingAB avatar Oct 27 '22 20:10 uNetworkingAB