6

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 ?

1 Answer 1

12

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.