ServerSocket
void main() async {
ServerSocket serverSocket = await ServerSocket.bind("localhost", 8888);
serverSocket.listen((Socket client) {
client.write("ok");
client.close();
});
}
Socket
Future<void> main() async {
Socket socket = await Socket.connect("localhost", 8888);
socket.listen((data) {
print(String.fromCharCodes(data));
}, onDone: (){
socket.destroy();
});
}
标签:8888,socket,dart,ServerSocket,client,main,Socket
From: https://www.cnblogs.com/sqmw/p/17027294.html