Reliable-UDP Library for Rust
This project is just Rust translation for KCP
Reliable-UDP Library for Rust
License: MIT License
Reliable-UDP Library for Rust
This project is just Rust translation for KCP
According to docs, Kcp::new_stream() creates a KCP control object in stream mode.
However I don't know what does stream mode means.
I can't find any concept or definition about stream mode from https://github.com/skywind3000/kcp/blob/master/README.en.md
Could give me some description about that?
Thank you in advance!
Errvalue: RecvQueueEmpty
usize 123
usize 124
usize 125
usize 126
usize 127
usize 128
thread 'main' panicked at src/bin/conn2.rs:36:42:
called Result::unwrap()
on an Err
value: RecvQueueEmpty`
I have conducted a simple investigation and it should be related to "const KCP_WND.RCV: u16=128;//must>=max fragment size", but this should not be an error. Is there a method to set it? I tried to modify this value to 500 The number of reads can exceed 128, but this should not be the method to fix this problem. At the same time, we also encountered a new issue where "kcp. set_wndsize (256, 256);" still outputs the same error at 256.
I wonder if I need to set certain values to avoid this issue, or if this is an unnoticed error?
https://github.com/Matrix-Zhang/kcp/blob/master/src/kcp.rs#L340
Thanks for your great work for this project.
What is the usage of these curly brackets? Just start learning Rust, so maybe this is a noob question.
:D
rcp2 never echos back, maybe there is something wrong with the “peer” in the “LatencySimulator::recv"
Call kcp.send() and kcp.flush() twice, the first call get output, but the second call get nothing.
use std::{sync::{Arc, Mutex}, collections::VecDeque};
use ::kcp::Kcp;
#[test]
fn test_kcp() {
let output = MockOutput::default();
let mut kcp = Kcp::new(123, output.clone());
kcp.update(now_millis()).unwrap();
let r = kcp.send("abc".as_bytes()).unwrap();
assert_eq!(r, 3);
let r = output.pop_front();
assert_eq!(r.is_some(), false, "{r:?}");
let _r = kcp.flush().unwrap();
let r = output.pop_front();
assert_eq!(r.is_some(), true, "{r:?}");
let r = kcp.send("def".as_bytes()).unwrap();
assert_eq!(r, 3);
let r = output.pop_front();
assert_eq!(r.is_some(), false, "{r:?}");
let _r = kcp.flush().unwrap();
let r = output.pop_front();
assert_eq!(r.is_some(), true, "{r:?}"); // <== panicked at here !!!!!!
}
#[derive(Default, Clone)]
struct MockOutput {
que: Arc<Mutex<VecDeque<WriteOp>>>
}
impl MockOutput {
fn pop_front(&self) -> Option<WriteOp> {
self.que.lock().unwrap().pop_front()
}
}
impl std::io::Write for MockOutput {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.que.lock().unwrap().push_back(WriteOp::Write(Vec::from(buf)));
Ok(buf.len())
}
fn flush(&mut self) -> std::io::Result<()> {
self.que.lock().unwrap().push_back(WriteOp::Flush);
Ok(())
}
}
#[derive(Debug)]
enum WriteOp {
Write(Vec<u8>),
Flush,
}
#[inline]
pub fn now_millis() -> u32 {
let start = std::time::SystemTime::now();
let since_the_epoch = start.duration_since(std::time::UNIX_EPOCH).expect("time went afterwards");
// (since_the_epoch.as_secs() * 1000 + since_the_epoch.subsec_millis() as u64) as u32
since_the_epoch.as_millis() as u32
}
Currently Kcp struct requires Write which makes integration with DTLS a little hard (since send_to
is async rather than sync) so what can we do to deal with this situation?
Thank you very much for your project, but I have referred to many different codes and still don't understand how to associate it with "std:: net:: UdpSocket". If your time permits and you are willing to provide a simple association to "std:: net:: UdpSocket", it will be of great help to me! Thank you again!
Hi,
Thanks for the crate.
Is that advisable for 500 bytes of data average? Is it as reliable as TCP in term of delivery (not order).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.