Skip to content

Instantly share code, notes, and snippets.

@mplacona
Created April 2, 2014 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mplacona/9930121 to your computer and use it in GitHub Desktop.
Save mplacona/9930121 to your computer and use it in GitHub Desktop.
import 'dart:io';
import 'dart:async';
final int port = 5000;
final String address = "127.0.0.1";
void main() {
Future<ServerSocket> serverFuture = ServerSocket.bind(address, port);
serverFuture.then((ServerSocket server) {
print('listening for connections on ' + server.port.toString());
server.listen((Socket socket) {
socket.listen((List<int> data) {
String cls = "Hi, I'm darty, your friendly little server";
socket.write(cls);
socket.close();
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment