uNetworking / uSockets

Miniscule cross-platform eventing, networking & crypto for async applications
Apache License 2.0
1.29k stars 267 forks source link

us_socket_transfer #175

Open abrownsword opened 2 years ago

abrownsword commented 2 years ago

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.

Jarred-Sumner commented 2 years ago

I might use this too

ghost commented 2 years ago

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

abrownsword commented 2 years ago

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.

uNetworkingAB commented 2 years ago

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