Skip to content

Instantly share code, notes, and snippets.

@XMPPwocky
Created January 3, 2015 00:04
Show Gist options
  • Save XMPPwocky/cf09cacabb0ebc835652 to your computer and use it in GitHub Desktop.
Save XMPPwocky/cf09cacabb0ebc835652 to your computer and use it in GitHub Desktop.
let len;
loop {
match socket.read(&mut buf) {
Ok(readlen) => { len = readlen; break; },
Err(IoError { kind: TimedOut, .. }) => (), // busywait
Err(e) => panic!("Failed reading from socket: {}", e)
}
}
// len now contains the number of valid bytes in buf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment