Use ServerSocket.bind() to bind to an address and a port. Get the socket from the ServerSocket and listen to it for the data.
import 'dart:io';
import 'dart:convert';
main() async {
var serverSocket = await ServerSocket.bind('127.0.0.1', 4041);
print('connected');
await for (var socket in serverSocket)
socket.transform(UTF8.decoder).listen(print);
}
查看更多关于使用 ServerSocket 构建服务端的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did129465