Code Monkey home page Code Monkey logo

h3-quiche's Introduction

h3-quiche

An experiment on gluing h3 and quiche together, more specifically, on implementing h3::quic with quiche.

Considerations

A quiche stream can be used via the combination of an established connection and a stream id, but can't be accessed publicly. This should probably be implemented from within the quiche project.

quiche provides a primitive API, which requires users to work with UDP sockets directly. We may also need to create a socket adaptor.

// UDP socket used for communication
let addr: SocketAddr = "127.0.0.1:0".parse()?;
let socket = tokio::net::UdpSocket::bind(addr).await?;

// QUIC connection
let conn = quiche::connect(None, &scid, local, peer, &mut config)?;

if conn.is_established() {
    // write to stream's send buffer
    conn.stream_send(stream_id, packet, false)?;
}

'send: loop {
    // write an outgoing packet each time, until `Done`
    let (len, send_info) = match { conn.send(&mut out_buf) } {
        Ok(v) => v,

        Err(quiche::Error::Done) => {
            break 'send;
        }

        Err(e) => {
            conn.close(false, 0x1, b"fail").ok();
            break 'send;
        }
    };

    // actually dispatch packet
    socket.send_to(&out_buf[..len], send_info.to).await?;
}

License

Licensed under either MIT or Apache License 2.0 at you option.

h3-quiche's People

Contributors

eagr avatar

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.