Created
April 14, 2015 21:45
-
-
Save ra1u/3e63032ac34dfc5848dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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