Commit ba376a9a authored by Thomas Gatzweiler's avatar Thomas Gatzweiler
Browse files

Flush stream after writing a packet

parent 85203b1f
......@@ -44,6 +44,8 @@ impl<W: Write> Connection<W> {
pub fn run(&mut self, mut stream: &mut Read) -> io::Result<()> {
self.stream.write(self.my_id.as_bytes())?;
self.stream.flush()?;
self.peer_id = Some(self.read_id(stream)?);
if let Some(ref peer_id) = self.peer_id {
......
......@@ -52,6 +52,7 @@ impl Packet {
stream.write_u8(padding_len as u8)?;
stream.write(&self.payload)?;
stream.write(&[0u8; 255][..padding_len])?;
stream.flush()?;
Ok(())
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment