Replies: 1 comment
-
Node has been supporting this feature for along time and I use it in most of my projects. It's just a bit frustrating when new JavaScript runtimes remove features that others see value in. Without the ability o make a server listen on a file descriptor it's not really possible to create a socket activated app. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I apologize if this has already been answered, I looked everywhere I could - I promise!
How does one use Deno.listen() to listen on an existing file descriptor / resource?
OR
Please allow Deno.listen() to listen on existing file descriptors / resources.
Similarly Deno.read(), Deno.write(), etc. allows one to read/write/etc. from a given resource id (which is obviously an essential function as files are a widely adopted system concept). Using the Deno documentation I was able to successfully utilize Deno.listen() to simultaneously create a socket() resource and to bind() to it, which is neat, but in some particular instances one would prefer not to (or can not) do that first step as there already exists a socket (that can still be bound to).
For example, the popular software spawn-fcgi creates a socket, executes a specified process, and assigns the socket to fd 0. Systemd is also a now popular software that creates a socket for your process (but I think it assigns it to fd 3?).
If this feature isn't yet available, may I suggest this syntax:
Deno.listen(0)
where 0 represents Deno's first resource. This makes it similar to Deno's read(), write(), etc functions and also virtually every other popular definition of listen() (see both posix and win32). I'd greatly prefer that syntax, but if that isn't acceptable then the next obvious form would beDeno.listen({rid: 0})
. Additionally, in my opinionDeno.listen({transport: "rid", rid: 0})
or similar is not preferable, but I also realize that it may be required if Deno needs to know whether the socket is a datagram socket or not.Also if this feature isn't yet available, could someone direct me towards some literature that illustrates how to utilize either op calls or Deno's newer FFI API to just use the system's listen() functionality in an async manner? With the instance I have in mind FFI and "unstable" is fine and listen() is available, but Deno.run() is not (nor is any foreign subprocessing functions).
Thank you!
Update: I just discovered op_net_accept which I'll attempt to experiment with, but some usage hints would still be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions