Properly close TCP socket. Fix #4

This commit is contained in:
Mohd Tarmizi 2015-12-06 16:19:51 +08:00
parent 576a378454
commit 3fbd635807
1 changed files with 3 additions and 0 deletions

View File

@ -100,6 +100,9 @@ impl Socket {
impl Drop for Socket {
fn drop(&mut self) {
unsafe { c::shutdown(self.inner, c::SHUT_WR); }
let mut buf = Vec::new();
self.read_to_end(&mut buf).ok();
unsafe { c::close(self.inner); }
}
}