Skip to content

Instantly share code, notes, and snippets.

@vadimtsushko
Created August 5, 2012 09:31
Show Gist options
  • Save vadimtsushko/3263357 to your computer and use it in GitHub Desktop.
Save vadimtsushko/3263357 to your computer and use it in GitHub Desktop.
Socket does not throw error on unsuccessfull connection
#import("dart:io");
Future<Socket> openConnection(){
var socket = new Socket('127.0.0.1', 1234567);
Completer completer = new Completer();
socket.onError = (e) {
print("connect exception ${e}");
completer.completeException(e);
};
socket.onConnect = () {
completer.complete(socket);
};
return completer.future;
}
void main() {
openConnection().then((socket)=>print(socket));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment