目前我可以使用 TCP 套接字:
final socket = await Socket.connect('127.0.0.1', 8888);
Run Code Online (Sandbox Code Playgroud)
我想使用UNIX 套接字。有没有办法用 Dart 做到这一点?
Dart 2.7.2 支持 UNIX 套接字(请参阅此 pr或此问题)。
您需要使用InternetAddress带有可选参数type设置为的构造函数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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
295 次 |
| 最近记录: |