advance-practice/frame #884
Replies: 5 comments 5 replies
-
请问如果缓冲区容量很大 那么要等到缓冲区满了才往socket写数据 是否会导致客户端一直等待 |
Beta Was this translation helpful? Give feedback.
-
在解析完成后,利用advance来将缓冲区该帧数据删除。这个地方我没有很理解。我们现在有一个BufMut, read_buf会写入并且update内部游标。而我们解析完数据后,调用advance也会update内部游标。这里的游标和read_buf 中的游标一样吗?感觉需要两个游标,一个标记当前的读入位置,一个标记当前的写入位置 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
求问这里: if 0 == self.stream.read_buf(&mut self.buffer).await? { |
Beta Was this translation helpful? Give feedback.
-
// 确保缓冲区长度足够
if self.buffer.len() == self.cursor {
// 若不够,需要增加缓冲区长度
self.buffer.resize(self.cursor * 2, 0);
} 这种扩容方式感觉还是不能保证缓冲区长度足够,还是应该封装一个结构体实现 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
advance-practice/frame
https://course.rs/advance-practice/frame.html
Beta Was this translation helpful? Give feedback.
All reactions