Comments (7)
这里不太清楚为啥用异步
send
,UdpSocket的send
倒是同步的。
KCP的设计 send
就是异步的,真实IO只会在update
和flush
时才会产生。
发送第129个的时候send会阻塞住,而不是返回error,而且即便
session
的timeout
到了也不会解除阻塞。
Lines 148 to 167 in db5b613
就是因为发送队列满了所以发不出去了。行为是合理的,用TCP如果对面一直不收,本地的socket buffer满了也是一样卡住。
是否可以考虑提供一个同步的
send_sync
函数?队列满了就直接返回报错。
那应该叫 try_send
,如果满了报错 EWOULDBLOCK
或者
send
在session
超时后返回一个报错?
Client Stream 实际上根本不会超时,服务端的 Stream 才会有超时。Client 端的 Session 只会在 KcpStream 实例析构时才会触发关闭逻辑,会唤醒所有等待在 send
的 Task
如果可以的话还希望可以考虑下在
KcpConfig
里提供这个队列长度上限的配置。
可以试下
Lines 68 to 69 in db5b613
from tokio_kcp.
try_send
也挺好的,不知实现起来难不难🥲
wnd_size
试了不会影响队列的配置,我试了(256, 256)
和(25600, 25600)
,都是只能缓存128个
from tokio_kcp.
Client Stream 实际上根本不会超时
这个之前确实不知道😢,因为用的另一个c#的kcp库的客户端倒是会超时,超时了send
会报错🤯,导致我以为rust这边差不多
我以为超时了tokio_kcp
的Client Stream
也会自动关闭套接字。。。
from tokio_kcp.
你可以加个超时,用 tokio::time::timeout
包在 send
调用上,这样就会超时了
from tokio_kcp.
真实IO只会在update和flush时才会产生
我可能哪里没理解对,我知道只有update
和flush
时才会IO,所以我的理解send
不是可以立即返回吗?send
又没有等待update
和flush
?
from tokio_kcp.
KCP的send
会不做任何限制地往snd_queue塞数据,最终会塞爆。因此在本项目如果已经积压超过上限,会主动等待。
from tokio_kcp.
Client 端的 Session 只会在 KcpStream 实例析构时才会触发关闭逻辑
这个是不是会导致内存泄漏?
服务端每秒钟向客户端发送60个逻辑帧,每次客户端离线退出时,服务端的send队列会残留128个包。
而服务端的KcpStream
是同一个一直运行着,不会产生析构,那是不是意味着这send队列里的包永远不会被释放?
我现在服务端这边内存泄漏非常严重,感觉会不会可能和这个有关系。。。。🤯🤯🤯
当我没说,一直运行着的是KcpSocket
,KcpStream
是会析构的,我再找找自己哪里搞出内存泄漏了。。。
from tokio_kcp.
Related Issues (20)
- Question about 0.8.0 version stability HOT 2
- one server, two client, conv not match HOT 9
- 依赖版本建议 HOT 1
- 引用报错 HOT 1
- Add some doc for architecture or design? HOT 2
- Never reaches EOF (or 0 bytes read) HOT 3
- How to create a kcp listener based on an existing UDP listener ? HOT 1
- socket in struct KcpSocket should not be Arc<UdpSocket> HOT 6
- Need some help with porting to Async_std HOT 2
- Request to let KcpStream support Debug Trait HOT 2
- Is it possible to provide an API that actively switches the underlying udp connection? HOT 1
- 能否支持icmp协议 HOT 3
- Bug: panic on receiving maliciously small packets HOT 2
- KcpStream blocks tokio runtime when the connection closed both physically and abruptly HOT 4
- Bug: panic on session's "input channel closed" HOT 2
- KcpSession io_task_handle loop 不结束 HOT 3
- feature request: support modifying datagram to allow customizable protocol header HOT 1
- Missing poll_accept
- 空data支持 HOT 38
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio_kcp.