title: UdpSocket.recv_from fails with "end of file" but I can see the incoming package in Wireshark
body: <blockquote>
    <p>Editor's note: This code example is from a version of Rust prior to 1.0 and is not valid Rust 1.0 code. The concepts discussed in the question are still valid.</p>
  </blockquote>
  
  <p>I'm experimenting with torrent scraping using Rust. I can see the incoming package in Wireshark, but my <code>recv_from</code> calls always return <code>Error("End of file")</code>. Here's my program:</p>
  
  <pre><code>use std::io::net::ip::{Ipv4Addr, SocketAddr};
  use std::io::net::udp::UdpSocket;
  use std::rand;
  
  use std::io::MemWriter;
  
  fn main() {
      let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 35000 };
      let mut socket = match UdpSocket::bind(addr) {
          Ok(s) =&gt; s,
          Err(e) =&gt; panic!("couldn't bind socket: {}", e),
      };
  
      let mut buf: Vec&lt;u8&gt; = Vec::with_capacity(1000);
  
      let transaction_id: u32 = rand::random();
      let mut req_data = MemWriter::with_capacity(16);
      req_data.write_be_u64(0x41727101980).unwrap(); // connection_id, identifies the protocol.
      req_data.write_be_u32(0).unwrap(); // action: connect
      req_data.write_be_u32(transaction_id).unwrap();
  
      println!("{}", socket.send_to(req_data.get_ref(), ("31.172.63.252", 80)));
  
      match socket.recv_from(buf.as_mut_slice()) {
          Ok((amt, src)) =&gt; {
              println!("Got {} bytes from {}.", amt, src);
          },
          Err(err) =&gt; println!("Can't recv_from: {}", err)
      }
  }
  </code></pre>
  
  <p>The output is always:</p>
  
  <pre class="lang-none prettyprint-override"><code>➜  udp-bug git:(master) ✗ cargo run
     Compiling udp-bug v0.0.1 (file:///home/omer/rust/udp-bug)
       Running `target/udp-bug`
  Ok(())
  Can't recv_from: end of file
  </code></pre>
  
  <p>However, I can see the expected response coming in Wireshark:</p>
  
  <pre class="lang-none prettyprint-override"><code>20235   3512.148636000  31.172.63.252   192.168.1.4 QUIC    60  CID: 0, Seq: 0
  </code></pre>
  
  <p>This package has a 16-byte payload, exactly what I expect. What's going wrong?</p>