aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorZachary Dremann <dremann@gmail.com>2014-06-12 13:48:49 -0400
committerZachary Dremann <dremann@gmail.com>2014-06-12 13:48:49 -0400
commit0dc97968422a078126dd9bf575002b335962b42c (patch)
treefcc8e84068702bb7c27687d894f322cff9bd8450 /examples
parentad4f61e29f3072fd7d9e78386439e52f8512287e (diff)
downloadrusty-irc-0dc97968422a078126dd9bf575002b335962b42c.tar.gz
rusty-irc-0dc97968422a078126dd9bf575002b335962b42c.zip
Close right away when connection is closed by remote
Diffstat (limited to 'examples')
-rw-r--r--examples/client.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/client.rs b/examples/client.rs
index 0419816..a48d2a6 100644
--- a/examples/client.rs
+++ b/examples/client.rs
@@ -1,4 +1,5 @@
extern crate irc;
+extern crate libc;
use std::io::stdio;
@@ -27,7 +28,7 @@ fn main() {
match line {
Ok(s) => {
match from_str(s.as_slice()) {
- Some(msg) => sender.send(msg),
+ Some(msg) => { if sender.send_opt(msg).is_err() { break; } },
None => ()
}
}
@@ -39,4 +40,6 @@ fn main() {
for msg in rx.iter() {
println!("{} {}", msg.prefix, msg.command);
}
+
+ unsafe { libc::exit(0); }
}