-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateC-bugCategory: This is a bug.Category: This is a bug.M-netModule: tokio/netModule: tokio/net
Description
Version
tokio v1.23.0
Platform
Windows 11 64-bit
Description
I'm using Tokio as a named pipe server. However, when reading data from a pipe, I"m only getting chunks with a max of 4096 bytes, even though my vector has a higher capacity.
I tried this code:
ASYNC_RUNTIME.spawn(async move {
let mut first_pipe_instance = true;
loop {
trace!("Creating pipe server with address {}", pipe_addr);
let server = ServerOptions::new()
.first_pipe_instance(first_pipe_instance)
.max_instances(1)
.create(&pipe_addr)
.unwrap();
first_pipe_instance = false;
trace!("Initiate connection to pipe client");
server.connect().await.unwrap();
let (mut server_reader, server_writer) = split(server);
trace!("Pipe client connected. Initiating pipe_reader loop");
loop {
let mut buf = Vec::with_capacity(1024 * 64);
match server_reader.read_buf(&mut buf).await {
Ok(0) => {
info!("Received 0 bytes, pipe closed by client");
break;
}
Ok(n) => {
trace!("read {} bytes", n);
}
Err(e) if e.kind() == WouldBlock => {
warn!("Reading pipe would block: {}", e);
continue;
}
Err(e) => {
error!("Error reading from pipe server: {}", e);
break;
}
}
}
}
})I expected to see this happen: When connecting to this pipe from a client and sending a message of 8192 bytes, I'd expect a message of 8192 bytes coming in at the sever's end.
Instead, this happened: The message came in as two chunks of 4096 bytes in size. It seems like there is a hard limit of 4096 bytes somewhere.
Metadata
Metadata
Assignees
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateC-bugCategory: This is a bug.Category: This is a bug.M-netModule: tokio/netModule: tokio/net