-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
2 weeksProjection of 2 week for this issue to be completed.Projection of 2 week for this issue to be completed.API BreakBreaks the APIBreaks the APIEnhancementNew feature or requestNew feature or requestMinorThis issue or PR contains minor changesThis issue or PR contains minor changes
Description
In an async server software you often have a loop which recv packets and some sort of client struct that contains a way to send packets.
This would mean we would either need to copy/clone the connection or split it.
Tokio's tcp stream has a nice way to split it into a recv half and write half.
use tokio::prelude::*;
use tokio::net::TcpStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = TcpStream::connect("localhost:8080").await?;
let (mut read, mut write) = tokio::io::split(stream);
tokio::spawn(async move {
loop {
let mut buf = [0u8; 32];
read.read(&mut buf).await.unwrap();
println!("{:?}", std::str::from_utf8(&buf));
}
});
Ok(())
}this code is from stack overflow
Even though Raknet uses udp it would still be nice if an api for splitting the connection or copying/cloning it would be added.
This is very important for writing effiecient server software that utilise multi threading.
honnisha and theaddonn
Metadata
Metadata
Assignees
Labels
2 weeksProjection of 2 week for this issue to be completed.Projection of 2 week for this issue to be completed.API BreakBreaks the APIBreaks the APIEnhancementNew feature or requestNew feature or requestMinorThis issue or PR contains minor changesThis issue or PR contains minor changes