Git Product home page Git Product logo

Comments (5)

carllerche avatar carllerche commented on May 17, 2024

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.

rrichardson avatar rrichardson commented on May 17, 2024

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.

rrichardson avatar rrichardson commented on May 17, 2024

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.

carllerche avatar carllerche commented on May 17, 2024

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.

carllerche avatar carllerche commented on May 17, 2024

Resolved by 0122914

from mio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.