id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/udp.rs:8 | server.connect(client.local_addr().unwrap()).await.unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send(b"hello world") {
Ok(n) => {
assert_eq!(n, 11);
break;
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/udp.rs:9 | // Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send_to(b"hello world", saddr) {
Ok(n) => {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/udp.rs:10 | let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
// Connect the two
client.connect(server.local_addr().unwrap()).await.unwrap();
server.connect(client.local_addr().unwrap()).await.unwrap();
for _ in 0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/udp.rs:11 | #[tokio::test]
async fn try_recv_buf_from() {
// Create listener
let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let saddr = server.local_addr().unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/udp.rs:12 | }
}
}
#[tokio::test]
async fn poll_ready() {
// Create listener
let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let saddr = server.local_addr().unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/udp.rs | 441 | 486 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind or UDP
use futures::future::poll_fn;
use std::io;
use std::sync::Arc;
use tokio::{io::ReadBuf, net::UdpSocket};
use tokio_test::assert_ok;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | let mut read = ReadBuf::new(&mut recv_buf);
let _len = poll_fn(|cx| receiver.poll_recv(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
Ok(())
}
#[tokio::test]
async fn send_to_recv_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind or UDP
use futures::future::poll_fn;
use std::io;
use std::sync::Arc;
use tokio::{io::ReadBuf, net::UdpSocket};
use tokio_test::assert_ok;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future::poll_fn;
use std::io;
use std::sync::Arc;
use tokio::{io::ReadBuf, net::UdpSocket};
use tokio_test::assert_ok;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | aea26b322c9493f732894265810837bf17a330ca | github | async-runtime | https://github.com/tokio-rs/tokio/blob/aea26b322c9493f732894265810837bf17a330ca/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future::poll_fn;
use std::io;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::{io::ReadBuf, net::UdpSocket};
use tokio_test::assert_ok;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
let _len = poll_fn(|cx| receiver.poll_recv(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
Ok(())
}
#[tokio::test]
async fn send_to_recv_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").awa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | #[tokio::test]
async fn send_to_peek_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?;
// peek
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/udp.rs:4 | assert_eq!(read.filled(), MSG);
assert_eq!(addr, sender.local_addr()?);
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
poll_fn(|cx| receiver.poll_peek_from(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
let mut recv_buf = [0u8; 32];
let mut read = ReadBu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/udp.rs:5 | let (tx, mut rx) = tokio::sync::mpsc::channel::<(Vec<u8>, std::net::SocketAddr)>(1_000);
tokio::spawn(async move {
while let Some((bytes, addr)) = rx.recv().await {
s.send_to(&bytes, &addr).await.unwrap();
}
});
tokio::spawn(async move {
let mut buf = [0u8; 32];
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/udp.rs:6 | });
tokio::spawn(async move {
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
loop {
let addr = poll_fn(|cx| r.poll_recv_from(cx, &mut read)).await.unwrap();
tx.send((read.filled().to_vec(), addr)).await.unwrap();
}
});
// t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/udp.rs:7 | .await
.unwrap();
sender.writable().await.unwrap();
let sent = &sender
.try_send_to(MSG, receiver.local_addr().unwrap())
.unwrap();
assert_eq!(sent, &MSG_LEN);
let mut buf = [0u8; 32];
let mut received = receiver.recv(&mut buf[..]).await.unwrap();
sender
.conne... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/udp.rs:8 | client.connect(server.local_addr().unwrap()).await.unwrap();
server.connect(client.local_addr().unwrap()).await.unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send(b"hello world") {
Ok(n) => {
assert_eq!(n... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/udp.rs:9 | // Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send_to(b"hello world", saddr) {
Ok(n) => {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/udp.rs:10 | // Create listener
let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
// Connect the two
client.connect(server.local_addr().unwrap()).await.unwrap();
server.connect(client.local_addr().unwrap()).await.un... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/udp.rs:11 | }
#[tokio::test]
async fn try_recv_buf_from() {
// Create listener
let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let saddr = server.local_addr().unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/udp.rs:12 | }
}
}
}
#[tokio::test]
async fn poll_ready() {
// Create listener
let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let saddr = server.local_addr().unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 441 | 496 |
tokio-rs/tokio:tokio/tests/udp.rs:13 | }
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!("{:?}", e),
}
}
}
}
#[tokio::test]
async fn peer_addr() {
let addr = "127.0.0.1:0".parse::<SocketAddr>().unwrap();
let peer_addr = "127.0.0.1:11100".parse::<SocketAddr>().... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a9d9bde0688cb88149272d78f8239a89b357974e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9d9bde0688cb88149272d78f8239a89b357974e/tokio/tests/udp.rs | 481 | 496 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future::poll_fn;
use std::io;
use std::sync::Arc;
use tokio::{io::ReadBuf, net::UdpSocket};
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let sender = UdpSocket::bind("1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | let _len = poll_fn(|cx| receiver.poll_recv(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
Ok(())
}
#[tokio::test]
async fn send_to_recv_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | async fn send_to_peek_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?;
// peek
let mut recv_buf... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/udp.rs:4 | assert_eq!(addr, sender.local_addr()?);
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
poll_fn(|cx| receiver.poll_peek_from(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
poll_fn(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/udp.rs:5 | tokio::spawn(async move {
while let Some((bytes, addr)) = rx.recv().await {
s.send_to(&bytes, &addr).await.unwrap();
}
});
tokio::spawn(async move {
let mut buf = [0u8; 32];
loop {
let (len, addr) = r.recv_from(&mut buf).await.unwrap();
tx.sen... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/udp.rs:6 | tokio::spawn(async move {
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
loop {
let addr = poll_fn(|cx| r.poll_recv_from(cx, &mut read)).await.unwrap();
tx.send((read.filled().to_vec(), addr)).await.unwrap();
}
});
// test that ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/udp.rs:7 | sender.writable().await.unwrap();
let sent = &sender
.try_send_to(MSG, receiver.local_addr().unwrap())
.unwrap();
assert_eq!(sent, &MSG_LEN);
let mut buf = [0u8; 32];
let mut received = receiver.recv(&mut buf[..]).await.unwrap();
sender
.connect(receiver.local_addr().unwrap... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/udp.rs:8 | for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send(b"hello world") {
Ok(n) => {
assert_eq!(n, 11);
break;
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/udp.rs:9 | let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send_to(b"hello world", saddr) {
Ok(n) => {
assert_eq!(n, 11);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/udp.rs:10 | // Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
// Connect the two
client.connect(server.local_addr().unwrap()).await.unwrap();
server.connect(client.local_addr().unwrap()).await.unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/udp.rs:11 | #[tokio::test]
async fn try_recv_buf_from() {
// Create listener
let server = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let saddr = server.local_addr().unwrap();
// Create socket pair
let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 3b6bee822dfe70caea7eb22b51fefb28d162f966 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3b6bee822dfe70caea7eb22b51fefb28d162f966/tokio/tests/udp.rs | 401 | 442 |
tokio-rs/tokio:tokio/tests/udp.rs:9 | let client = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let caddr = client.local_addr().unwrap();
for _ in 0..5 {
loop {
client.writable().await.unwrap();
match client.try_send_to(b"hello world", saddr) {
Ok(n) => {
assert_eq!(n, 11);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 16c2e0983cc0ab22f9a0b7a1ac37ea32a42b9a6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/16c2e0983cc0ab22f9a0b7a1ac37ea32a42b9a6e/tokio/tests/udp.rs | 321 | 355 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | let _len = poll_fn(|cx| receiver.poll_recv(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
Ok(())
}
#[tokio::test]
async fn send_to_recv_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 0ea23076503c5151d68a781a3d91823396c82949 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0ea23076503c5151d68a781a3d91823396c82949/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | async fn send_to_peek_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
poll_fn(|cx| sender.poll_send_to(cx, MSG, &receiver_addr)).await?;
// peek
let mut recv_bu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 0ea23076503c5151d68a781a3d91823396c82949 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0ea23076503c5151d68a781a3d91823396c82949/tokio/tests/udp.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/udp.rs:5 | tokio::spawn(async move {
while let Some((bytes, addr)) = rx.recv().await {
s.send_to(&bytes, &addr).await.unwrap();
}
});
tokio::spawn(async move {
let mut buf = [0u8; 32];
loop {
let (len, addr) = r.recv_from(&mut buf).await.unwrap();
tx.sen... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 0ea23076503c5151d68a781a3d91823396c82949 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0ea23076503c5151d68a781a3d91823396c82949/tokio/tests/udp.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/udp.rs:6 | tokio::spawn(async move {
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
loop {
let addr = poll_fn(|cx| r.poll_recv_from(cx, &mut read)).await.unwrap();
tx.send((read.filled().to_vec(), addr)).await.unwrap();
}
});
// test that ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 0ea23076503c5151d68a781a3d91823396c82949 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0ea23076503c5151d68a781a3d91823396c82949/tokio/tests/udp.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use futures::future::poll_fn;
use std::sync::Arc;
use tokio::{io::ReadBuf, net::UdpSocket};
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | assert_eq!(read.filled(), MSG);
Ok(())
}
#[tokio::test]
async fn send_to_recv_from() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
sender.send_to(MSG, &receiver_addr).aw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
poll_fn(|cx| sender.poll_send_to(cx, MSG, &receiver_addr)).await?;
// peek
let mut recv_buf = [0u8; 32];
let (n, addr) = receiver.peek_from(&mut... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/udp.rs:4 | let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
poll_fn(|cx| receiver.poll_peek_from(cx, &mut read)).await?;
assert_eq!(read.filled(), MSG);
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
poll_fn(|cx| receiver.poll_recv_from(cx, &mut read)).... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/udp.rs:5 | while let Some((bytes, addr)) = rx.recv().await {
s.send_to(&bytes, &addr).await.unwrap();
}
});
tokio::spawn(async move {
let mut buf = [0u8; 32];
loop {
let (len, addr) = r.recv_from(&mut buf).await.unwrap();
tx.send((buf[..len].to_vec(), addr)).awa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/udp.rs:6 | let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
loop {
let addr = poll_fn(|cx| r.poll_recv_from(cx, &mut read)).await.unwrap();
tx.send((read.filled().to_vec(), addr)).await.unwrap();
}
});
// test that we can send a value and get back s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/udp.rs:7 | let sent = &sender
.try_send_to(MSG, receiver.local_addr().unwrap())
.unwrap();
assert_eq!(sent, &MSG_LEN);
let mut buf = [0u8; 32];
let mut received = receiver.recv(&mut buf[..]).await.unwrap();
sender
.connect(receiver.local_addr().unwrap())
.await
.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/358e4f9f8029b6b289f8ef5a54bd7c6eae5bf969/tokio/tests/udp.rs | 241 | 265 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::sync::Arc;
use tokio::net::UdpSocket;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | dfdfd61372cca02087c0e2773dc978d03235bc51 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dfdfd61372cca02087c0e2773dc978d03235bc51/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | }
#[tokio::test]
async fn split() -> std::io::Result<()> {
let socket = UdpSocket::bind("127.0.0.1:0").await?;
let s = Arc::new(socket);
let r = s.clone();
let addr = s.local_addr()?;
tokio::spawn(async move {
s.send_to(MSG, &addr).await.unwrap();
});
let mut recv_buf = [0u8; 32];
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | dfdfd61372cca02087c0e2773dc978d03235bc51 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dfdfd61372cca02087c0e2773dc978d03235bc51/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | // test that we can send a value and get back some response
let sender = UdpSocket::bind("127.0.0.1:0").await?;
sender.send_to(MSG, addr).await?;
let mut recv_buf = [0u8; 32];
let (len, _) = sender.recv_from(&mut recv_buf).await?;
assert_eq!(&recv_buf[..len], MSG);
Ok(())
}
// # Note
//
// This... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | dfdfd61372cca02087c0e2773dc978d03235bc51 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dfdfd61372cca02087c0e2773dc978d03235bc51/tokio/tests/udp.rs | 81 | 136 |
tokio-rs/tokio:tokio/tests/udp.rs:4 | .await
.unwrap();
let sent = &sender.try_send(MSG2).unwrap();
assert_eq!(sent, &MSG2_LEN);
received += receiver.recv(&mut buf[..]).await.unwrap();
std::thread::spawn(move || {
let sent = &sender.try_send(MSG).unwrap();
assert_eq!(sent, &MSG_LEN);
})
.join()
.unwrap()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | dfdfd61372cca02087c0e2773dc978d03235bc51 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dfdfd61372cca02087c0e2773dc978d03235bc51/tokio/tests/udp.rs | 121 | 136 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::sync::Arc;
use tokio::net::UdpSocket;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let sender = UdpSocket::bind("127.0.0.1:0").await?;
let receiver = UdpSocket::bind("1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a0557840eb424e174bf81a0175c40f9e176a2cc2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | }
#[tokio::test]
async fn split() -> std::io::Result<()> {
let socket = UdpSocket::bind("127.0.0.1:0").await?;
let s = Arc::new(socket);
let r = s.clone();
let addr = s.local_addr()?;
tokio::spawn(async move {
s.send_to(MSG, &addr).await.unwrap();
});
let mut recv_buf = [0u8; 32];
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a0557840eb424e174bf81a0175c40f9e176a2cc2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | .try_send_to(MSG, receiver.local_addr().unwrap())
.unwrap();
assert_eq!(sent, &MSG_LEN);
let mut buf = [0u8; 32];
let mut received = receiver.recv(&mut buf[..]).await.unwrap();
sender
.connect(receiver.local_addr().unwrap())
.await
.unwrap();
let sent = &sender.try_s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | a0557840eb424e174bf81a0175c40f9e176a2cc2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a0557840eb424e174bf81a0175c40f9e176a2cc2/tokio/tests/udp.rs | 81 | 104 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::net::UdpSocket;
const MSG: &[u8] = b"hello";
const MSG_LEN: usize = MSG.len();
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let mut sender = UdpSocket::bind("127.0.0.1:0").await?;
let mut receiver = UdpSocket::bind("127.0.0.1:0")... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 1562bb314482215eb7517e6b8b8bdecbacf10e79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1562bb314482215eb7517e6b8b8bdecbacf10e79/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | #[tokio::test]
async fn split() -> std::io::Result<()> {
let socket = UdpSocket::bind("127.0.0.1:0").await?;
let (mut r, mut s) = socket.split();
let addr = s.as_ref().local_addr()?;
tokio::spawn(async move {
s.send_to(MSG, &addr).await.unwrap();
});
let mut recv_buf = [0u8; 32];
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 1562bb314482215eb7517e6b8b8bdecbacf10e79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1562bb314482215eb7517e6b8b8bdecbacf10e79/tokio/tests/udp.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/udp.rs:3 | // If data is sent and not yet received, attempting to send more data will
// result in `ErrorKind::WouldBlock` until the first operation completes.
#[tokio::test]
async fn try_send_spawn() {
const MSG2: &[u8] = b"world!";
const MSG2_LEN: usize = MSG2.len();
let sender = UdpSocket::bind("127.0.0.1:0").awai... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 1562bb314482215eb7517e6b8b8bdecbacf10e79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1562bb314482215eb7517e6b8b8bdecbacf10e79/tokio/tests/udp.rs | 81 | 120 |
tokio-rs/tokio:tokio/tests/udp.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::net::UdpSocket;
#[tokio::test]
async fn send_recv() -> std::io::Result<()> {
let mut sender = UdpSocket::bind("127.0.0.1:0").await?;
let mut receiver = UdpSocket::bind("127.0.0.1:0").await?;
sender.connect(receiver.local_addr()?).await?;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/udp.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/udp.rs:2 | #[tokio::test]
async fn split() -> std::io::Result<()> {
let socket = UdpSocket::bind("127.0.0.1:0").await?;
let (mut r, mut s) = socket.split();
let msg = b"hello";
let addr = s.as_ref().local_addr()?;
tokio::spawn(async move {
s.send_to(msg, &addr).await.unwrap();
});
let mut recv... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/udp.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/udp.rs | 41 | 73 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(unix, not(target_os = "dragonfly"), not(miri)))] // No `getsockopt` on miri.
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "netbsd",
ignore = "NetBSD does not support getpeereid() for so... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_cred.rs | 1 | 57 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(unix, not(target_os = "dragonfly"), not(miri)))] // No `getsockopt` on miri.
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "netbsd",
ignore = "NetBSD does not support getpeereid() for so... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/uds_cred.rs | 1 | 26 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(unix, not(target_os = "dragonfly"), not(miri)))]
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "netbsd",
ignore = "NetBSD does not support getpeereid() for sockets created by socketpair(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_cred.rs | 1 | 26 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(unix, not(target_os = "dragonfly")))]
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "netbsd",
ignore = "NetBSD does not support getpeereid() for sockets created by socketpair()"
)]
async... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | 2c24a028f6e4f2aea2b3975deeba92142f3d149b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2c24a028f6e4f2aea2b3975deeba92142f3d149b/tokio/tests/uds_cred.rs | 1 | 26 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(unix, not(target_os = "dragonfly")))]
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "freebsd",
ignore = "Requires FreeBSD 12.0 or later. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | b047f647b70acaedb282dabf5dd3a28ee90c2060 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b047f647b70acaedb282dabf5dd3a28ee90c2060/tokio/tests/uds_cred.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(unix, not(target_os = "dragonfly")))]
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "freebsd",
ignore = "Requires FreeBSD 12.0 or later. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/uds_cred.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/uds_cred.rs:1 | #![cfg(unix)]
#![cfg(not(target_os = "dragonfly"))]
use tokio::net::UnixStream;
use libc::getegid;
use libc::geteuid;
#[tokio::test]
#[cfg_attr(
target_os = "freebsd",
ignore = "Requires FreeBSD 12.0 or later. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=176419"
)]
#[cfg_attr(
target_os = "netbsd",
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_cred.rs | MIT | 227533d456fe32e48ffcd3796f1e6c8f9318b230 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/227533d456fe32e48ffcd3796f1e6c8f9318b230/tokio/tests/uds_cred.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
use tokio::io::ReadBuf;
use tokio::net::UnixDatagram;
use tokio::try_join;
use std::future::poll_fn;
use std::io;
use std::sync::Arc;
async fn echo_server(socket: UnixDatagram) -> io::Result<()> {
let mut recv_buf = vec![0u8; 1024];
loop {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:2 | let len = socket.recv(&mut recv_buf[..]).await?;
assert_eq!(&recv_buf[..len], b"ECHO");
}
Ok(())
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn echo_from() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:3 | let (dgram1, dgram2) = UnixDatagram::pair()?;
// Send until we hit the OS `net.unix.max_dgram_qlen`.
loop {
dgram1.writable().await.unwrap();
match dgram1.try_send(payload) {
Err(err) => match (err.kind(), err.raw_os_error()) {
(io::ErrorKind::WouldBlock, _) => brea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:4 | #[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn split() -> std::io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("split.sock");
let s = Arc::new(UnixDatagram::bind(path.clone())?);
let r = s.clone();
let msg = b"hello";
let ((), ()) =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:5 | let addr = poll_fn(|cx| receiver.poll_recv_from(cx, &mut read)).await?;
assert_eq!(read.filled(), msg);
assert_eq!(addr.as_pathname(), Some(sender_path.as_ref()));
Ok(())
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn send_recv_poll() -> std::io::Result<()> {
let dir = tem... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:6 | // Create socket pair
let client = UnixDatagram::bind(&client_path)?;
for _ in 0..5 {
loop {
client.writable().await?;
match client.try_send_to(b"hello world", &server_path) {
Ok(n) => {
assert_eq!(n, 11);
break;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:7 | #[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn try_recv_buf_from() -> std::io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
let client_path = dir.path().join("client.sock");
// Create listener
let server = UnixDatagram::bind(&ser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:8 | }
}
}
Ok(())
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn recv_buf_from() -> std::io::Result<()> {
let tmp = tempfile::tempdir()?;
// Bind each socket to a filesystem path
let tx_path = tmp.path().join("tx");
let tx = UnixDatagram::bind(&tx_path)?;
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:9 | loop {
dgram1.writable().await.unwrap();
match dgram1.try_send(payload) {
Err(err) => match (err.kind(), err.raw_os_error()) {
(io::ErrorKind::WouldBlock, _) => break,
(_, Some(libc::ENOBUFS)) => break,
_ => {
panic!("unexp... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:10 | #[cfg_attr(miri, ignore)] // No SOCK_DGRAM for `socketpair` in miri.
async fn recv_buf() -> std::io::Result<()> {
// Create the pair of sockets
let (sock1, sock2) = UnixDatagram::pair()?;
// Since the sockets are paired, the paired send/recv
// functions can be used
let bytes = b"hello world";
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:11 | Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!("{e:?}"),
}
}
loop {
poll_fn(|cx| server.poll_recv_ready(cx)).await?;
let mut buf = Vec::with_capacity(512);
match server.try_recv_buf_from(&mut buf) {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/uds_datagram.rs | 401 | 425 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]
use tokio::io::ReadBuf;
use tokio::net::UnixDatagram;
use tokio::try_join;
use std::future::poll_fn;
use std::io;
use std::sync::Arc;
async fn echo_server(socket: UnixDatagram) -> io::Result<()> {
let mut recv_buf = vec![0u8; 1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:2 | let len = socket.recv(&mut recv_buf[..]).await?;
assert_eq!(&recv_buf[..len], b"ECHO");
}
Ok(())
}
#[tokio::test]
async fn echo_from() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
let client_path = dir.path().join("client.soc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:3 | // Send until we hit the OS `net.unix.max_dgram_qlen`.
loop {
dgram1.writable().await.unwrap();
match dgram1.try_send(payload) {
Err(err) => match (err.kind(), err.raw_os_error()) {
(io::ErrorKind::WouldBlock, _) => break,
(_, Some(libc::ENOBUFS)) => brea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:4 | let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("split.sock");
let s = Arc::new(UnixDatagram::bind(path.clone())?);
let r = s.clone();
let msg = b"hello";
let ((), ()) = try_join! {
async {
s.send_to(msg, path).await?;
io::Result::Ok(())
},... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:5 | Ok(())
}
#[tokio::test]
async fn send_recv_poll() -> std::io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let sender_path = dir.path().join("sender.sock");
let receiver_path = dir.path().join("receiver.sock");
let sender = UnixDatagram::bind(&sender_path)?;
let receiver = UnixDatagram::bi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:6 | client.writable().await?;
match client.try_send_to(b"hello world", &server_path) {
Ok(n) => {
assert_eq!(n, 11);
break;
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:7 | let server = UnixDatagram::bind(&server_path)?;
// Create socket pair
let client = UnixDatagram::bind(&client_path)?;
for _ in 0..5 {
loop {
client.writable().await?;
match client.try_send_to(b"hello world", &server_path) {
Ok(n) => {
as... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:8 | #[tokio::test]
async fn recv_buf_from() -> std::io::Result<()> {
let tmp = tempfile::tempdir()?;
// Bind each socket to a filesystem path
let tx_path = tmp.path().join("tx");
let tx = UnixDatagram::bind(&tx_path)?;
let rx_path = tmp.path().join("rx");
let rx = UnixDatagram::bind(&rx_path)?;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:9 | }
},
Ok(len) => {
assert_eq!(len, payload.len());
}
}
count += 1;
}
// Read every dgram we sent.
while count > 0 {
let mut recv_buf = Vec::with_capacity(16);
dgram2.readable().await.unwrap();
let len = dgram2.try_r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:10 | let mut buff = Vec::with_capacity(24);
let size = sock2.recv_buf(&mut buff).await?;
let dgram = &buff[..size];
assert_eq!(dgram, bytes);
Ok(())
}
#[tokio::test]
async fn poll_ready() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 361 | 414 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:11 | Ok((n, addr)) => {
assert_eq!(n, 11);
assert_eq!(addr.as_pathname(), Some(client_path.as_ref()));
assert_eq!(&buf[0..11], &b"hello world"[..]);
break;
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/tests/uds_datagram.rs | 401 | 414 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:2 | let len = socket.recv(&mut recv_buf[..]).await?;
assert_eq!(&recv_buf[..len], b"ECHO");
}
Ok(())
}
#[tokio::test]
async fn echo_from() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
let client_path = dir.path().join("client.soc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:3 | // Send until we hit the OS `net.unix.max_dgram_qlen`.
loop {
dgram1.writable().await.unwrap();
match dgram1.try_send(payload) {
Err(err) => match (err.kind(), err.raw_os_error()) {
(io::ErrorKind::WouldBlock, _) => break,
(_, Some(libc::ENOBUFS)) => brea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:5 | Ok(())
}
#[tokio::test]
async fn send_recv_poll() -> std::io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let sender_path = dir.path().join("sender.sock");
let receiver_path = dir.path().join("receiver.sock");
let sender = UnixDatagram::bind(&sender_path)?;
let receiver = UnixDatagram::bi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:6 | client.writable().await?;
match client.try_send_to(b"hello world", &server_path) {
Ok(n) => {
assert_eq!(n, 11);
break;
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:7 | let server = UnixDatagram::bind(&server_path)?;
// Create socket pair
let client = UnixDatagram::bind(&client_path)?;
for _ in 0..5 {
loop {
client.writable().await?;
match client.try_send_to(b"hello world", &server_path) {
Ok(n) => {
as... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:8 | #[tokio::test]
async fn recv_buf_from() -> std::io::Result<()> {
let tmp = tempfile::tempdir()?;
// Bind each socket to a filesystem path
let tx_path = tmp.path().join("tx");
let tx = UnixDatagram::bind(&tx_path)?;
let rx_path = tmp.path().join("rx");
let rx = UnixDatagram::bind(&rx_path)?;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:10 | let mut buff = Vec::with_capacity(24);
let size = sock2.recv_buf(&mut buff).await?;
let dgram = &buff[..size];
assert_eq!(dgram, bytes);
Ok(())
}
#[tokio::test]
async fn poll_ready() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 361 | 414 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:11 | Ok((n, addr)) => {
assert_eq!(n, 11);
assert_eq!(addr.as_pathname(), Some(client_path.as_ref()));
assert_eq!(&buf[0..11], &b"hello world"[..]);
break;
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/uds_datagram.rs | 401 | 414 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
use tokio::io::ReadBuf;
use tokio::net::UnixDatagram;
use tokio::try_join;
use std::future::poll_fn;
use std::io;
use std::sync::Arc;
async fn echo_server(socket: UnixDatagram) -> io::Result<()> {
let mut recv_buf = vec![0u8; 1024];
loop {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/uds_datagram.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:2 | assert_eq!(&recv_buf[..len], b"ECHO");
}
Ok(())
}
#[tokio::test]
async fn echo_from() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
let client_path = dir.path().join("client.sock");
let server_socket = UnixDatagram::bind(server_p... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/uds_datagram.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:3 | // Send until we hit the OS `net.unix.max_dgram_qlen`.
loop {
dgram1.writable().await.unwrap();
match dgram1.try_send(payload) {
Err(err) => match (err.kind(), err.raw_os_error()) {
(io::ErrorKind::WouldBlock, _) => break,
(_, Some(libc::ENOBUFS)) => brea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/uds_datagram.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:4 | let path = dir.path().join("split.sock");
let s = Arc::new(UnixDatagram::bind(path.clone())?);
let r = s.clone();
let msg = b"hello";
let ((), ()) = try_join! {
async {
s.send_to(msg, path).await?;
io::Result::Ok(())
},
async {
let mut recv_bu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/uds_datagram.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:5 | }
#[tokio::test]
async fn send_recv_poll() -> std::io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let sender_path = dir.path().join("sender.sock");
let receiver_path = dir.path().join("receiver.sock");
let sender = UnixDatagram::bind(&sender_path)?;
let receiver = UnixDatagram::bind(&rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/uds_datagram.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/uds_datagram.rs:6 | match client.try_send_to(b"hello world", &server_path) {
Ok(n) => {
assert_eq!(n, 11);
break;
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!("{:?}", e),
}
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/uds_datagram.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/tests/uds_datagram.rs | 201 | 260 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.