I'm building a desktop app in Flutter with a Go backend and I'd like to use Unix Domain Socket as the IPC between the two languages. I wrote a server and client in Go for prototyping, and it's working fine on Windows, but when I ported the client code to Dart I get the error:
Connection failed (OS Error: Unix domain sockets are not available on this operating system.)
When I run the command sc query afunix on the terminal, it shows a service, which means UDS is available in my version of Windows 10.
I found this recent commit which states dart:io support UDS on Windows https://dart.googlesource.com/sdk/+/e50d3b98a3569e8ecb884f9acb53387a6f5af75d , but on the documentation page it doesn't mention Windows. Here is the code:
Future<void> main() async {
const socketPath = '/tmp/my_socket.sock';
final socket = await Socket.connect(
InternetAddress(socketPath, type: InternetAddressType.unix),
0,
);
Am I doing something wrong, or there is no support as of right now (I'm using Dart 3.10.4)?
The feature are scheduled to be part of Dart 3.11.0 which are currently in beta:
Added support for Unix domain sockets (
AF_UNIX) on Windows. Support is restricted to subset of features supported by the OS. Windows currently does not support the following features forAF_UNIXsockets: datagram sockets, ancillary data or abstract socket addresses. Unix domain sockets are represented in the file-system using reparse points which leads to some discrepancies in the behavior ofdart:ioAPIs: for exampleFile(socketPath).existsSync()will returntrueon POSIX operating systems, butfalseon Windows. UseFileSystemEntity.typeSync()instead to get portable behavior.
https://github.com/dart-lang/sdk/blob/beta/CHANGELOG.md#3110
If you download the current beta version of Dart 3.11.0, it should already be part of it and ready for testing: https://dart.dev/get-dart/archive#beta-channel
Please report any issues you might find: https://github.com/dart-lang/sdk/issues