GithubHelp home page GithubHelp logo

Satisfy net.Conn about smux HOT 12 CLOSED

xtaci avatar xtaci commented on August 18, 2024
Satisfy net.Conn

from smux.

Comments (12)

xtaci avatar xtaci commented on August 18, 2024

how to implement SetWriteDeadline(t time.Time) error for different streams on the same connection?

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

Well yamux does it somehow.

from smux.

xtaci avatar xtaci commented on August 18, 2024

but with problem

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

What problem?
I mean it's not feasible to have any networking library if you might end up hanging indefinately or for unreasonable amounts of time (say 30 seconds on a handshake)

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

As for implementation it's trivial, all the deadlines do is promise that next calls will not block for longer than X, no other sematics are implied by that.

from smux.

xtaci avatar xtaci commented on August 18, 2024

you have to set the underlying connection's WriteDeadLine to the closest one of all streams, or else, it will block when sockbuf is full.

so a possible solution is by maintaining a min-heap for deadline. when the closest deadline has reached, switch to the next one.

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

I think it's perfectly fine to discard data at some later point (after the write has returned), the idea is just not to block on the write for too long, if the send queue is full or something like that.

from smux.

xtaci avatar xtaci commented on August 18, 2024

you can't guarantee that if you do not set write deadline to for example TCPConn.

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

Well I suspect it's fine for the dispatching routine to block indefinately or to maintain a continious 1s deadline itself internally, yet it doesn't need to be related to the deadline of the stream.

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

I guess you need a deadline for Accept() on the session for example.

from smux.

xtaci avatar xtaci commented on August 18, 2024

continuous 1s interrupt doesn't guarantee the atomicity of conn.Write for various underlying connections , you have to handle 'wrote incomplete data' problem, especially for TCPConn.

from smux.

AudriusButkevicius avatar AudriusButkevicius commented on August 18, 2024

Fine, you can probably get away without a deadline there as the write call would return upon a close of tye connection anyway, not causing any routine leaks.

from smux.

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.