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/tcp_into_std.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io::Read;
use std::io::Result;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpListener;
use tokio::net::TcpStream;
#[tokio::test]
async fn tcp_into_std() -> Result<()> {
let mut data = [0u8; 12];
let listener = TcpListener::bind("... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_into_std.rs | MIT | 21264f1d33474338815865c9d3fa8b5a7bb4c6f1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/21264f1d33474338815865c9d3fa8b5a7bb4c6f1/tokio/tests/tcp_into_std.rs | 1 | 45 |
tokio-rs/tokio:tokio/tests/tcp_into_std.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io::Read;
use std::io::Result;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpListener;
use tokio::net::TcpStream;
#[tokio::test]
async fn tcp_into_std() -> Result<()> {
let mut data = [0u8; 12];
let listener = TcpListener::bind("... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_into_std.rs | MIT | 0707f4c19210d6dac620c663e94d34834714a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0707f4c19210d6dac620c663e94d34834714a7c9/tokio/tests/tcp_into_std.rs | 1 | 44 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support peeking
// No `socket` on miri.
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_peek.rs | 1 | 37 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 042433cdccdf0dd33408c1751a80ddd50a077872 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/042433cdccdf0dd33408c1751a80ddd50a077872/tokio/tests/tcp_peek.rs | 1 | 37 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_peek.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListen... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListener::bind("1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListener::bind("127.0.0.1... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 0c8e8248f8de281f22ad6f30b967053f44fff66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0c8e8248f8de281f22ad6f30b967053f44fff66e/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{convert::TryInto, io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListene... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{convert::TryInto, io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListene... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{convert::TryInto, io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::Tc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{convert::TryInto, io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = lis... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | d593c5b051f07bde5117122216a356632986b6dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d593c5b051f07bde5117122216a356632986b6dd/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_peek.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncReadExt;
use tokio::net::TcpStream;
use tokio_test::assert_ok;
use std::thread;
use std::{convert::TryInto, io::Write, net};
#[tokio::test]
async fn peek() {
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = lis... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_peek.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/tcp_peek.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support mulithreading
// No `socket` on miri.
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
us... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_shutdown.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:2 | let handle = tokio::spawn(async move {
let mut stream = assert_ok!(TcpStream::connect(&addr).await);
connected_tx.send(()).unwrap();
dropped_rx.await.unwrap();
assert_ok!(AsyncWriteExt::shutdown(&mut stream).await);
});
let (stream, _) = assert_ok!(srv.accept().await);
// B... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_shutdown.rs | 41 | 81 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_shutdown.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use std::time::Duration;
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_shutdown.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:2 | let (connected_tx, connected_rx) = channel();
let (dropped_tx, dropped_rx) = channel();
let handle = tokio::spawn(async move {
let mut stream = assert_ok!(TcpStream::connect(&addr).await);
connected_tx.send(()).unwrap();
dropped_rx.await.unwrap();
assert_ok!(AsyncWriteExt::shut... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_shutdown.rs | 41 | 83 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use std::time::Duration;
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 421a7b001c762a25c0b009c9ffb86f0661608f90 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/421a7b001c762a25c0b009c9ffb86f0661608f90/tokio/tests/tcp_shutdown.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:2 | let (dropped_tx, dropped_rx) = channel();
let handle = tokio::spawn(async move {
let mut stream = assert_ok!(TcpStream::connect(&addr).await);
connected_tx.send(()).unwrap();
dropped_rx.await.unwrap();
assert_ok!(AsyncWriteExt::shutdown(&mut stream).await);
});
let (stream... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 421a7b001c762a25c0b009c9ffb86f0661608f90 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/421a7b001c762a25c0b009c9ffb86f0661608f90/tokio/tests/tcp_shutdown.rs | 41 | 82 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio_t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_shutdown.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let srv = assert_ok!(TcpListener:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_shutdown.rs | 1 | 28 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let srv = assert_ok!(TcpListener::bind("127.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_shutdown.rs | 1 | 28 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let srv = assert_ok!(TcpListener::bind("127.0.0.1:0"... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_shutdown.rs | 1 | 28 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let srv = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
let addr = assert_ok!(srv.local_addr(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 78f2340d259487d4470681f97cc4b5eac719e178 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/78f2340d259487d4470681f97cc4b5eac719e178/tokio/tests/tcp_shutdown.rs | 1 | 28 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{self, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::prelude::*;
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let srv = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
let addr = assert_ok!(srv.lo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 066965cd59d01fd9d999152e32169a24dfe434fa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/066965cd59d01fd9d999152e32169a24dfe434fa/tokio/tests/tcp_shutdown.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::{self, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio::prelude::*;
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let mut srv = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
let addr = assert_ok!(sr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 3ecaa6d91cef271b4c079a2e28bc3270280bcee6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ecaa6d91cef271b4c079a2e28bc3270280bcee6/tokio/tests/tcp_shutdown.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_shutdown.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncWriteExt;
use tokio::net::{TcpListener, TcpStream};
use tokio::prelude::*;
use tokio_test::assert_ok;
#[tokio::test]
async fn shutdown() {
let mut srv = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
let addr = assert_ok!(srv.local_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_shutdown.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/tcp_shutdown.rs | 1 | 29 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
// WASIp1 doesn't support bind
// No `socket` on miri.
#![cfg(all(
feature = "net",
feature = "macros",
feature = "rt",
feature = "io-util",
not(all(target_os = "wasi", target_env = "p1")),
not(miri)
))]
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_te... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:2 | let srv = assert_ok!(srv.listen(128));
// Create client & connect
let addr = srv.local_addr().unwrap();
let cli = assert_ok!(TcpSocket::new_v6());
let _cli = assert_ok!(cli.connect(addr).await);
// Accept
let _ = assert_ok!(srv.accept().await);
}
#[tokio::test]
async fn bind_before_connect() ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_socket.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:3 | srv.set_zero_linger().unwrap();
assert_eq!(srv.linger().unwrap(), Some(Duration::new(0, 0)));
}
/// Macro to create a simple test to set and get a socket option.
macro_rules! test {
// Test using the `arg`ument as expected return value.
($( #[ $attr: meta ] )* $get_fn: ident, $set_fn: ident ( $arg: expr ) ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_socket.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:4 | let arg = $arg;
assert_ne!(initial, arg, "initial value and argument are the same");
socket.$set_fn(arg).expect("failed to set option");
let got = socket.$get_fn().expect("failed to get value");
let expected = $expected;
assert_eq!(got, expected, "set and get values differ");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_socket.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:5 | set_recv_buffer_size(SET_BUF_SIZE),
GET_BUF_SIZE
);
test!(
#[cfg_attr(target_os = "wasi", ignore = "WASI does not yet support `SO_LINGER`")]
#[expect(deprecated, reason = "set_linger is deprecated")]
linger,
set_linger(Some(Duration::from_secs(10)))
);
test!(nodelay, set_nodelay(true));
#[cfg(any... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_socket.rs | 161 | 195 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | d89e998922724de80996802721e167d9ca24f4d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d89e998922724de80996802721e167d9ca24f4d7/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:2 | // Accept
let _ = assert_ok!(srv.accept().await);
}
#[tokio::test]
async fn bind_before_connect() {
// Create server
let any_addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(any_addr));
let srv = assert_ok!(srv.listen(128));
// Creat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | d89e998922724de80996802721e167d9ca24f4d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d89e998922724de80996802721e167d9ca24f4d7/tokio/tests/tcp_socket.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:3 | test!($( #[$attr] )* $get_fn, $set_fn($arg), $arg);
};
($( #[ $attr: meta ] )* $get_fn: ident, $set_fn: ident ( $arg: expr ), $expected: expr ) => {
#[test]
$( #[$attr] )*
fn $get_fn() {
test!(__ new_v4, $get_fn, $set_fn($arg), $expected);
#[cfg(not(target_os = "v... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | d89e998922724de80996802721e167d9ca24f4d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d89e998922724de80996802721e167d9ca24f4d7/tokio/tests/tcp_socket.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:4 | const SET_BUF_SIZE: u32 = 4096;
// Linux doubles the buffer size for kernel usage, and exposes that when
// retrieving the buffer size.
#[cfg(not(any(target_os = "android", target_os = "linux")))]
const GET_BUF_SIZE: u32 = SET_BUF_SIZE;
#[cfg(any(target_os = "android", target_os = "linux"))]
const GET_BUF_SIZE: u32 =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | d89e998922724de80996802721e167d9ca24f4d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d89e998922724de80996802721e167d9ca24f4d7/tokio/tests/tcp_socket.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:5 | test!(nodelay, set_nodelay(true));
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin",
))]
test!(IPv6 tclass_v6, set_tcla... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | d89e998922724de80996802721e167d9ca24f4d7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d89e998922724de80996802721e167d9ca24f4d7/tokio/tests/tcp_socket.rs | 161 | 184 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:3 | test!($( #[$attr] )* $get_fn, $set_fn($arg), $arg);
};
($( #[ $attr: meta ] )* $get_fn: ident, $set_fn: ident ( $arg: expr ), $expected: expr ) => {
#[test]
$( #[$attr] )*
fn $get_fn() {
test!(__ new_v4, $get_fn, $set_fn($arg), $expected);
#[cfg(not(target_os = "v... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_socket.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:4 | const SET_BUF_SIZE: u32 = 4096;
// Linux doubles the buffer size for kernel usage, and exposes that when
// retrieving the buffer size.
#[cfg(not(target_os = "linux"))]
const GET_BUF_SIZE: u32 = SET_BUF_SIZE;
#[cfg(target_os = "linux")]
const GET_BUF_SIZE: u32 = 2 * SET_BUF_SIZE;
test!(keepalive, set_keepalive(true)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_socket.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:2 | // Accept
let _ = assert_ok!(srv.accept().await);
}
#[tokio::test]
async fn bind_before_connect() {
// Create server
let any_addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(any_addr));
let srv = assert_ok!(srv.listen(128));
// Creat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 7388f2d2ea5311af4b2fa0e088d890facfbf4054 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/tcp_socket.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:3 | ($( #[ $attr: meta ] )* $get_fn: ident, $set_fn: ident ( $arg: expr ) ) => {
test!($( #[$attr] )* $get_fn, $set_fn($arg), $arg);
};
($( #[ $attr: meta ] )* $get_fn: ident, $set_fn: ident ( $arg: expr ), $expected: expr ) => {
#[test]
$( #[$attr] )*
fn $get_fn() {
test... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 7388f2d2ea5311af4b2fa0e088d890facfbf4054 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/tcp_socket.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:4 | }
const SET_BUF_SIZE: u32 = 4096;
// Linux doubles the buffer size for kernel usage, and exposes that when
// retrieving the buffer size.
#[cfg(not(target_os = "linux"))]
const GET_BUF_SIZE: u32 = SET_BUF_SIZE;
#[cfg(target_os = "linux")]
const GET_BUF_SIZE: u32 = 2 * SET_BUF_SIZE;
test!(keepalive, set_keepalive(tr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 7388f2d2ea5311af4b2fa0e088d890facfbf4054 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/tcp_socket.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:5 | );
test!(nodelay, set_nodelay(true));
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin",
))]
test!(IPv6 tclass_v6, set_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 7388f2d2ea5311af4b2fa0e088d890facfbf4054 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7388f2d2ea5311af4b2fa0e088d890facfbf4054/tokio/tests/tcp_socket.rs | 161 | 185 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:2 | // Accept
let _ = assert_ok!(srv.accept().await);
}
#[tokio::test]
async fn bind_before_connect() {
// Create server
let any_addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(any_addr));
let srv = assert_ok!(srv.listen(128));
// Creat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_socket.rs | 41 | 76 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:2 | // Accept
let _ = assert_ok!(srv.accept().await);
}
#[tokio::test]
async fn bind_before_connect() {
// Create server
let any_addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(any_addr));
let srv = assert_ok!(srv.listen(128));
// Creat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_socket.rs | 41 | 75 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:2 | let _ = assert_ok!(srv.accept().await);
}
#[tokio::test]
async fn bind_before_connect() {
// Create server
let any_addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(any_addr));
let srv = assert_ok!(srv.listen(128));
// Create client & con... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_socket.rs | 41 | 74 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | e5e88551d2be7655ee71771533168d4fe9ea7793 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e5e88551d2be7655ee71771533168d4fe9ea7793/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 808d52563e234769d2fc296ff17ca12173735d9e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::time::Duration;
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 22e6aef6e776b00ce36f8c7e003f475d9bd18242 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22e6aef6e776b00ce36f8c7e003f475d9bd18242/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(addr));
let srv = ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | 066965cd59d01fd9d999152e32169a24dfe434fa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/066965cd59d01fd9d999152e32169a24dfe434fa/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_socket.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::net::TcpSocket;
use tokio_test::assert_ok;
#[tokio::test]
async fn basic_usage_v4() {
// Create server
let addr = assert_ok!("127.0.0.1:0".parse());
let srv = assert_ok!(TcpSocket::new_v4());
assert_ok!(srv.bind(addr));
let mut srv =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_socket.rs | MIT | a9a59ea90eb0fc242bef3bed12986425b66206ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a9a59ea90eb0fc242bef3bed12986425b66206ee/tokio/tests/tcp_socket.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support peeking
// No `socket` on miri.
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_split.rs | 1 | 43 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
// No `socket` on miri.
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, A... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | 4047d7962a02722859b0f1c7bbcd85bc1bfc865d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4047d7962a02722859b0f1c7bbcd85bc1bfc865d/tokio/tests/tcp_split.rs | 1 | 43 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
const M... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
const MSG: &[u8... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | fc9518b62714daac9a38b46c698b94ac5d5b1ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fc9518b62714daac9a38b46c698b94ac5d5b1ca2/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
const MSG: &[u8... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
const M... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
const MSG: &[u8] = b"split";
let listener = net::TcpListener:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | db0d6d75b3b65812837c8561269e55eab00a74dd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/db0d6d75b3b65812837c8561269e55eab00a74dd/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_split.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use std::io::Result;
use std::io::{Read, Write};
use std::{net, thread};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
#[tokio::test]
async fn split() -> Result<()> {
const MSG: &[u8] = b"split";
let listener = net::TcpListener:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_split.rs | MIT | 7f580071f3e5d475db200d2101ff35be0b4f6efe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f580071f3e5d475db200d2101ff35be0b4f6efe/tokio/tests/tcp_split.rs | 1 | 42 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1 | #![warn(rust_2018_idioms)]
// WASIp1 doesn't support bind
// No `socket` on miri.
#![cfg(all(
feature = "net",
feature = "macros",
feature = "rt",
feature = "io-util",
not(all(target_os = "wasi", target_env = "p1")),
not(miri)
))]
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use toki... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2 | assert_ok!(stream.set_linger(None));
assert!(stream.linger().unwrap().is_none());
}
#[tokio::test]
#[cfg_attr(
target_os = "wasi",
ignore = "temporarily disabled for WASI pending https://github.com/WebAssembly/wasi-libc/pull/734"
)]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn try_read_write(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3 | let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());
match client.try_write(DATA) {
Ok(n) => written.extend(&DATA[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
break;
}
Err(e) => panic!("e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4 | loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());
match client.try_write_vectored(&data_bufs) {
Ok(n) => {
written.extend(&DATA[..n]);
}
Err(ref e) if e.kind() == io::ErrorKind:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5 | }
// Now, we listen for shutdown
drop(client);
#[cfg(not(target_os = "wasi"))] // WASI does not yet support `POLLHUP` or `POLLRDHUP`
{
loop {
let ready = server.ready(Interest::READABLE).await.unwrap();
if ready.is_read_closed() {
return;
} ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6 | let n = mem::size_of_val(&fut);
assert!(n < 1000);
}
macro_rules! assert_readable_by_polling {
($stream:expr) => {
assert_ok!(poll_fn(|cx| $stream.poll_read_ready(cx)).await);
};
}
macro_rules! assert_not_readable_by_polling {
($stream:expr) => {
poll_fn(|cx| {
assert_pendi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7 | // Initial state - not readable.
assert_not_readable_by_polling!(server);
// There is data in the buffer - readable.
assert_ok!(client.write_all(b"ping").await);
assert_readable_by_polling!(server);
// Readable until calls to `poll_read` return `Poll::Pending`.
let mut buf = [0u8; 4];
asse... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8 | let (client, (server, _)) = assert_ok!(try_join!(TcpStream::connect(&addr), listener.accept()));
(client, server)
}
fn read_until_pending(stream: &mut TcpStream) -> usize {
let mut buf = vec![0u8; 1024 * 1024];
let mut total = 0;
loop {
match stream.try_read(&mut buf) {
Ok(n) => tot... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9 | async fn try_read_buf() {
const DATA: &[u8] = b"this is some data to write to the socket";
// Create listener
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
// Create socket pair
let client = TcpStream::connect(listener.local_addr().unwrap())
.await
.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:10 | {
// Write buffer full
let mut writable = task::spawn(client.writable());
assert_pending!(writable.poll());
// Drain the socket from the server end
let mut read = Vec::with_capacity(written.len());
let mut i = 0;
while i < read.capacity() {
server.re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:11 | }
}
}
}
// read_closed is a best effort event, so test only for no false positives.
#[tokio::test]
#[cfg_attr(
target_os = "wasi",
ignore = "temporarily disabled for WASI pending https://github.com/WebAssembly/wasi-libc/pull/732"
)]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn read_cl... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/tcp_stream.rs | 401 | 447 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8 | let (client, (server, _)) = assert_ok!(try_join!(TcpStream::connect(&addr), listener.accept()));
(client, server)
}
fn read_until_pending(stream: &mut TcpStream) -> usize {
let mut buf = vec![0u8; 1024 * 1024];
let mut total = 0;
loop {
match stream.try_read(&mut buf) {
Ok(n) => tot... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 43134f1e5784993eb4fb3863933d74ac9e28f598 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/tcp_stream.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9 | let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
// Create socket pair
let client = TcpStream::connect(listener.local_addr().unwrap())
.await
.unwrap();
let (server, _) = listener.accept().await.unwrap();
let mut written = DATA.to_vec();
// Track the server receiving... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 43134f1e5784993eb4fb3863933d74ac9e28f598 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/tcp_stream.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:10 | assert_pending!(writable.poll());
// Drain the socket from the server end
let mut read = Vec::with_capacity(written.len());
let mut i = 0;
while i < read.capacity() {
server.readable().await.unwrap();
match server.try_read_buf(&mut read) {
Ok(n)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 43134f1e5784993eb4fb3863933d74ac9e28f598 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/tcp_stream.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:11 | // read_closed is a best effort event, so test only for no false positives.
#[tokio::test]
#[cfg_attr(
target_os = "wasi",
ignore = "temporarily disabled for WASI pending https://github.com/WebAssembly/wasi-libc/pull/732"
)]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn read_closed() {
let (cli... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 43134f1e5784993eb4fb3863933d74ac9e28f598 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/43134f1e5784993eb4fb3863933d74ac9e28f598/tokio/tests/tcp_stream.rs | 401 | 443 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::{TcpListener, TcpStream};
use tokio::try_join;
use tokio_test::task;
use tokio_test::{assert_ok, assert_pending, assert_ready_ok};
use... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2 | let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
// Create socket pair
let client = TcpStream::connect(listener.local_addr().unwrap())
.await
.unwrap();
let (server, _) = listener.accept().await.unwrap();
let mut written = DATA.to_vec();
// Track the server receiving... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3 | assert_pending!(writable.poll());
// Drain the socket from the server end using non-vectored I/O
let mut read = vec![0; written.len()];
let mut i = 0;
while i < read.len() {
server.readable().await.unwrap();
match server.try_read(&mut read[i..]) {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4 | let mut writable = task::spawn(client.writable());
assert_pending!(writable.poll());
// Drain the socket from the server end using vectored I/O
let mut read = vec![0; written.len()];
let mut i = 0;
while i < read.len() {
server.readable().await.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5 | use std::mem;
const N: usize = 4096;
let fut = async {
let stream = TcpStream::connect("127.0.0.1:8080").await.unwrap();
loop {
stream.readable().await.unwrap();
let mut buf = [0; N];
let n = stream.try_read(&mut buf[..]).unwrap();
if n == 0 {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6 | ($stream:expr) => {
assert_ok!(poll_fn(|cx| $stream.poll_write_ready(cx)).await);
};
}
macro_rules! assert_not_writable_by_polling {
($stream:expr) => {
poll_fn(|cx| {
assert_pending!($stream.poll_write_ready(cx));
Poll::Ready(())
})
.await;
};
}
#[t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7 | #[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn poll_write_ready() {
let (mut client, server) = create_pair().await;
// Initial state - writable.
assert_writable_by_polling!(client);
// No space to write - not writable.
write_until_pending(&mut client);
assert_not_writable_by_pollin... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8 | let mut total = 0;
loop {
match stream.try_write(&buf) {
Ok(n) => total += n,
Err(err) => {
assert_eq!(err.kind(), io::ErrorKind::WouldBlock);
break;
}
}
}
total
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9 | // Fill the write buffer
loop {
// Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());
match client.try_write(DATA) {
Ok(n) => written.extend(&DATA[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:10 | loop {
let ready = server.ready(Interest::READABLE).await.unwrap();
if ready.is_read_closed() {
return;
} else {
tokio::task::yield_now().await;
}
}
}
// read_closed is a best effort event, so test only for no false positives.
#[tokio::test]
#[cfg_attr(miri,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 361 | 410 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:11 | let mut read_size = 0;
while read_size < write_size {
server.readable().await.unwrap();
read_size += read_until_pending(&mut server);
}
let ready_event = assert_ok!(ready_fut.await);
assert!(!ready_event.is_write_closed());
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | f1cb007a281d49104e7b0e29d4ba5c6e7a06af11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f1cb007a281d49104e7b0e29d4ba5c6e7a06af11/tokio/tests/tcp_stream.rs | 401 | 410 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::{TcpListener, TcpStream};
use tokio::try_join;
use tokio_test::task;
use tokio_test::{assert_ok, assert_pending, assert_ready_ok};
use... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:2 | let client = TcpStream::connect(listener.local_addr().unwrap())
.await
.unwrap();
let (server, _) = listener.accept().await.unwrap();
let mut written = DATA.to_vec();
// Track the server receiving data
let mut readable = task::spawn(server.readable());
assert_pending!(readable.poll(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:3 | let mut read = vec![0; written.len()];
let mut i = 0;
while i < read.len() {
server.readable().await.unwrap();
match server.try_read(&mut read[i..]) {
Ok(n) => i += n,
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:4 | // Drain the socket from the server end using vectored I/O
let mut read = vec![0; written.len()];
let mut i = 0;
while i < read.len() {
server.readable().await.unwrap();
let mut bufs: Vec<_> = read[i..]
.chunks_mut(0x10000)
.map(io::IoSli... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:5 | let fut = async {
let stream = TcpStream::connect("127.0.0.1:8080").await.unwrap();
loop {
stream.readable().await.unwrap();
let mut buf = [0; N];
let n = stream.try_read(&mut buf[..]).unwrap();
if n == 0 {
break;
}
}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:6 | }
macro_rules! assert_not_writable_by_polling {
($stream:expr) => {
poll_fn(|cx| {
assert_pending!($stream.poll_write_ready(cx));
Poll::Ready(())
})
.await;
};
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn poll_read_ready() {
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:7 | // Initial state - writable.
assert_writable_by_polling!(client);
// No space to write - not writable.
write_until_pending(&mut client);
assert_not_writable_by_polling!(client);
// Detect the server disconnect.
drop(server);
assert_writable_by_polling!(client);
}
async fn create_pair() ->... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:8 | Ok(n) => total += n,
Err(err) => {
assert_eq!(err.kind(), io::ErrorKind::WouldBlock);
break;
}
}
}
total
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn try_read_buf() {
const DATA: &[u8] = b"this is some data to wr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:9 | // Still ready
let mut writable = task::spawn(client.writable());
assert_ready_ok!(writable.poll());
match client.try_write(DATA) {
Ok(n) => written.extend(&DATA[..n]),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
break;
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/tcp_stream.rs:10 | if ready.is_read_closed() {
return;
} else {
tokio::task::yield_now().await;
}
}
}
// read_closed is a best effort event, so test only for no false positives.
#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn read_closed() {
let (client, mut serve... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/tcp_stream.rs | MIT | 3bf2e53f0b65833824e71b6a0532513004d65d4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bf2e53f0b65833824e71b6a0532513004d65d4e/tokio/tests/tcp_stream.rs | 361 | 407 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.