Comments (2)
如果是 UDP,你可以尝试增加 ReadBufferCap,这样每次读取的包就可以更大,如果是 TCP,因为其本身就是流式协议,分包的逻辑你需要自己完成,尝试增加 ReadBufferCap
也只是治标不治本,因为每次 TCP 读取不能保证读出来的数据大小,你只能按照你自己的应用层协议进行分包,每次都尝试读一个完整的包,不完整就不消费数据即可,参考这个例子.
from gnet.
我使用的是tcp,进行文件的传输。我在v2版本的时候,第一个版本拆解包没问题了,通过OnTraffic触发时取数据长度如果超长,缓存这次的数据,下次数据触发OnTraffic的时候补齐,这里很丑陋,要自己缓存一下。第二版本,我一次性的调用conn的read方法,读取所有的数据,但是即使我只发送一个文件,读取到完整文件数据后,后面仍然触发OnTraffic方法,让我没办法判断是否有新数据。然后我回到V1版本去使用,但是发送大文件时,服务端很久很久才会触发OnTraffic,也会卡住后面的消息处理。我不是很清楚这方面的逻辑,golang也用的不是很熟悉,帮忙解答下。
from gnet.
Related Issues (20)
- [Bug]: Calling Dial() in version 2.4 of Windows 10 will block HOT 4
- [Question]: I would like to verify whether this problem in the screenshot will cause the memory of the service to slowly increase. HOT 1
- [Feature]: support edge-triggered I/O
- [Question]: Is the netpoll v1 version defaulting to horizontal triggering, and the V2 version defaulting to edge triggering? HOT 15
- [Bug]: fatal error: concurrent map read and map write HOT 1
- Inconsistent behaviors with SO_REUSEPORT on Linux and *BSD HOT 7
- Don't use SO_REUSEPORT on Unix domain sockets HOT 1
- Don't disable SO_REUSEPORT on DragonFlyBSD HOT 1
- [Question]: gnet client works not as expected even tho i did it according to the api ref HOT 1
- [Bug]: GNET client not working as expected HOT 4
- [Bug]: example gnet for echo tcp uses too much memory HOT 7
- [Bug]: Read returns io.ErrShortBuffer on closed connection HOT 7
- Special treatment for the first package HOT 8
- [Question]: How to shut down the started tcp server and turn off port listening? HOT 2
- [Question]: When using io.CopyBuffer(), do you need to call Flush to send the data? HOT 2
- [Bug]: Discard() panic HOT 17
- [Feature]: `io_uring` support HOT 6
- [Question]: there's gnet https server now, how to use gnet https client? HOT 1
- UDP FD handle is not released HOT 1
- [Question]: The redis server service implemented using gnet has too many read tcp i/o timeouts in the production environment. HOT 6
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 gnet.