Support Unix Sockets in dart:io #21403

Open
schultzter opened this Issue Oct 23, 2014 · 15 comments

Comments

Projects
None yet
9 participants

What steps will clearly show the issue / need for enhancement?

  1. a lot of Unix based systems use Unix sockets for interprocess communication
  2. with dart:io only TCP based communication is possible
  3. support for Unix sockets would greatly increase the integration potential of dart server-side apps

What is the current output?
None, not supported

What would you like to see instead?
Success, connected!

What version of the product are you using? On what operating system?
1.7.2 on Arch Linux

Please provide any additional information below.

Member

lrhn commented Oct 24, 2014

Added Library-IO, Area-Library, Triaged labels.

DartBot commented Nov 14, 2014

This comment was originally written by @PaulAnnekov


It's very important feature. Unix sockets are lighter than TCP/IP Sockets. They will be useful for nginx + dart setup where you need to proxy requests from nginx to dart server that listens for requests.

DartBot commented Apr 20, 2015

This comment was originally written by @kaendfinger


This is a great idea, but I'm pretty sure you can use the Unix "Everything is a file" principle to make it work for now.

Member

sgjesse commented Apr 20, 2015

In the dart:io model there is currently no way of creating/listing/deleting a Unix Domain socket, and the also listening is only supported for TCP/IP or UDP.

DartBot commented Apr 20, 2015

This comment was originally written by @PaulAnnekov


  1. It's not the right way. I think it's not a big deal for dart developers to add ability to set AF_UNIX socket family in the same way as AF_INET is set. Plus add support for family address as file name. The only problem is backward compatibility with current Dart Socket API.
  2. read() and write() functions are not aliases for recv() and send(). You will have to write a lot of code to repeat all their features using plain I/O functions. "Everything is a file" principle will lead to the wheel reinvention.
Contributor

zoechi commented Dec 11, 2015

Any progress on this? I think to remember that I saw a commit or code review where this was mentioned not too long ago, but I might mix up something. I'd like to use this to connect to docker services. It's possible to configure Docker to accept http connections but that results in severe security issues.

Member

sgjesse commented Dec 11, 2015

We have been experimenting with adding support for UNIX domain sockets, and is currently using a patched Dart VM for some experimentation. However I don't expect this to be added after all, as we will try to move the experimental use we have back to TCP sockets.

For reference the experimental patch is here: https://codereview.chromium.org/1293533002/.

Contributor

zoechi commented Dec 11, 2015

@sgjesse Thanks a lot for this quick response!
Doesn't seem to add a lot of complexity.
What are the reasons for this changes being dropped?

Member

sgjesse commented Dec 11, 2015

The change is not complete - it is missing changes to the File class where
we currently also don't handle domain sockets (the patch have a hack to
allow one to delete this type of files).

Another concern is to add platform specific APIs dart:io. If this should be
abstracted to also have a Windows counterpart we would have to find a
matching IPC concept on Windows, which would increase the complexity quite
a bit.

On Fri, Dec 11, 2015 at 12:44 PM, Günter Zöchbauer <notifications@github.com

wrote:

@sgjesse https://github.com/sgjesse Thanks a lot for this quick
response!
Doesn't seem to add a lot of complexity.
What are the reasons for this changes being dropped?


Reply to this email directly or view it on GitHub
#21403 (comment).

Contributor

zoechi commented Dec 11, 2015

I understand that reasoning, but it's sad to limit Darts usage on Unix systems this way because Windows doesn't provide anything similar :(

@kevmoo kevmoo added Type: enhancement and removed triaged labels Mar 1, 2016

Pajn commented Aug 5, 2016

Is there any development in this area?

There are many cross-platform languages that support Unix Sockets on platforms that have support for it and does not provide an alternative on Windows. The alternative already exist in the form of TCP and UDP, it's just a much worse alternative for certain use-cases.

Redis with Unix sockets can support around 50% more throughput than with TCP sockets, it's sad to have to think of that and have that as a thing to consider when choosing a server platform.

I want to attempt to write a very simple X11 client in Dart. Is Unix sockets really off the table? That would be quite sad in my opinion.

Contributor

zoechi commented Jul 31, 2017

Another concern is to add platform specific APIs dart:io. If this should be
abstracted to also have a Windows counterpart we would have to find a
matching IPC concept on Windows, which would increase the complexity quite
a bit.

This missing feature prevents several use cases which don't apply to Windows, because they are not used much on Windows but are a significant limitation on Unix systems.

Perhaps there can be a dart:unix library for unix specific APIs?

Contributor

Hixie commented Oct 8, 2017

FWIW, this is the workaround I used (to send the string status\n to a Unix domain socket named /tmp/control.socket):

await Process.run('/bin/sh', <String>['-c', 'echo status | nc -U /tmp/control.socket']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment