Skip to content

Instantly share code, notes, and snippets.

@ra1u
Created April 14, 2015 21:45
Show Gist options
  • Save ra1u/3e63032ac34dfc5848dd to your computer and use it in GitHub Desktop.
Save ra1u/3e63032ac34dfc5848dd to your computer and use it in GitHub Desktop.
import 'dart:io';
int PORT = 5555;
void testconnect(){
print("testconnect");
Socket.connect("localhost", PORT).then((Socket sock){
sock.add("hello".codeUnits);
});
}
void testlisten(){
ServerSocket.bind("localhost", PORT).then((ServerSocket socket) {
socket.listen((Socket clientSocket) {
print("new client");
clientSocket.listen((data) => clientSocket.add(data) //echo data back
,onDone:()=> print("close client") );
});
});
}
main() {
testlisten();
testconnect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment