Currently I can use a TCP socket :
final socket = await Socket.connect('127.0.0.1', 8888);
I would like to use a UNIX socket. Is there a way to do this with Dart ?
Currently I can use a TCP socket :
final socket = await Socket.connect('127.0.0.1', 8888);
I would like to use a UNIX socket. Is there a way to do this with Dart ?
UNIX sockets are supported in Dart 2.7.2 (see this pr or this issue).
You need to use InternetAddress
constructor with the optional parameter type
set as unix
:
import 'dart:io';
...
// With String address
final host = InternetAddress(address, type: InternetAddressType.unix);
// OR with UInt8List raw address
final host = InternetAddress.fromRawAddress(rawAddress, type: InternetAddressType.unix);
final socket = await Socket.connect(host, port);