Unix socket bidirectional communication #15363
Unanswered
caramboleyo
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Wrong question. The client doesn't listen, it reads. |
Beta Was this translation helpful? Give feedback.
1 reply
-
There are several abstractions in
While a lot of libraries say "listen" that is a higher order abstraction, as @bnoordhuis, you are reading and writing to the socket. A decent example is in socks /lib/client.ts. A server then is simply an abstraction on top of a client. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With Deno.listen i can listen to a unix socket file and with Deno.connect i can send data to that socket from another app. What does not work is to have it bidirectional. When i listen to a socket from another app, it deletes and recreates the socket file, the first app listening to it no longer reacts when sending. In #9052 @bnoordhuis says this is expected behavior and that node does it the same way, but i had this bidirectional communication with node a few years ago. I was playing around the whole day (mostly to understand how the buffer works, this worked out of the box with node) and this is what I came up with:
(I also tried Alice/Bob example with Deno.listenDatagram but that does not work when you put alice and bob in separate scripts).
service.js:
cli.js:
I dont understand why you delete the socket file. The main reason for unix sockets is for different applications to communicate with each other, even if they use completly different programming languages. Or did i get something wrong about that?
Beta Was this translation helpful? Give feedback.
All reactions