Comments (5)
I'm not sure that I am entirely following, but it seems like the solution would be to implement different versions of read()
for TcpSocket
vs. UdpSocket
where the UdpSocket
implementation is different and returns after each call to os::read()
. Is that correct? I personally don't have any experience working with UDP sockets, so I can't really say.
from mio.
I actually need this functionality for TCP. It actually makes more sense for most TCP protocols, HTTP for example. Most streaming protocols are chunked up into messages that fit into segments.
When read() is called on a stream socket. It will read 1 segment and only 1 segment. I tend to ensure that messages fit inside a single segment, so if I read twice, I expect that I've received 2 messages. If something else reads for me, and it reads twice into the same buffer, now I'm left with two messages catted together that I can't parse (or am not expecting to parse)
from mio.
So I think the answer here is for read to only call read once. If you're using a stream buffer which expects to fill its buffer every time, it should just call read in its own loop, it should not be part of io, or it would be a separate function in io
from mio.
Alright, I'm OK with just removing the loop from the MIO read()
API in favor of a single call to os::read()
from mio.
Resolved by 0122914
from mio.
Related Issues (20)
- The UnixStream has an FD leakage problem. HOT 4
- Continue or break while would_block error in tcpStream read loop? HOT 3
- any workaround to allow registering to different Poll? HOT 8
- A way to add EPOLLPRI event type to the epoll selector HOT 7
- Master doc page out of date? HOT 2
- Windows named pipes hits unreachable code during read operation HOT 1
- Can TcpStream be read from a different thread? HOT 1
- Exposing `AsRawHandle` on `Registry` HOT 5
- build failed with wasm-pack HOT 1
- Wait for messages in the error queue HOT 6
- Setup WASM/WASI CI
- get any errors when i use `wasm-pack` command by `mio` HOT 4
- Need switch to not use eventfd on `target_os = "linux"` HOT 4
- Add ESP-IDF framework support
- IoRing support for windows HOT 1
- Has waker check doesn't work with try_cloned Registries HOT 1
- compile time error inside `poll.rs` HOT 3
- poll: Optimize locks and allocations in the critical path
- Poll(2) implementation follow-ups
- Official ESP-IDF framework support HOT 3
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 mio.