All Projects → status-im → nim-quic

status-im / nim-quic

Licence: other
QUIC for Nim

Programming Languages

nim
578 projects

QUIC for Nim

We're working towards an implementation of the QUIC protocol for Nim. This is very much a work in progress, and not yet in a usable state.

Building and testing

Install dependencies:

nimble install -d

Run tests:

nimble test

Examples

Import quic and the chronos async library:

import quic
import chronos

Outgoing connections

Connect to a QUIC peer:

let connection = await dial(initTAddress("127.0.0.1:12345"))

Open a new stream:

let stream = await connection.openStream()

Write to the stream:

let message = cast[seq[byte]]("some message")
await stream.write(message)

Close stream:

await stream.close()

Wait for peer to close connection:

await connection.waitClosed()

Incoming connections

Listen for incoming connections:

let listener = listen(initTAddress("127.0.0.1:12345"))

Accept an incoming connection:

let connection = await listener.accept()

Wait for an incoming stream:

let stream = await connection.incomingStream()

Read from a stream:

let message = await stream.read()

Close stream:

await stream.close()

Close connection:

await connection.close()

Stop listening:

await listener.stop()

Roadmap

This is a rough outline of the steps that we expect to take during implementation. They are bound to change over time.

Thanks

We would like to thank the authors of the NGTCP2 library, on whose work we're building.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].