Skip to content

Instantly share code, notes, and snippets.

@ethan-tqa
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save ethan-tqa/85f367c000115bfe5faa to your computer and use it in GitHub Desktop.

Select an option

Save ethan-tqa/85f367c000115bfe5faa to your computer and use it in GitHub Desktop.
#[test]
fn test_net()
{
let server_port = 12321;
let mut serverSock = UdpSocket::bind(("127.0.0.1", server_port)).unwrap();
let mut clientSock = UdpSocket::bind(("0.0.0.0:0")).unwrap();
clientSock.send_to("Hello World\r\n".as_bytes(), (Ipv4Addr::new(127, 0, 0, 1), server_port));
println!("lol");
let mut buf = [0; 20];
serverSock.recv_from(&mut buf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment