QUIC for Nim
Go to file
Mark Spanbroek 087be3a1b9 Limit size of stream queue
Writing to streams is blocked when the maximum stream offset
is reached. Previously we extended this offset when data was
*added* to the read queue of the receiving peer. Now we only
extend it once data has been *removed* from the queue,
thereby limiting the queue size.
2021-01-21 17:21:25 +01:00
.github/workflows Set CI timeout to 10 minutes 2020-11-25 18:00:32 +01:00
quic Limit size of stream queue 2021-01-21 17:21:25 +01:00
tests Limit size of stream queue 2021-01-21 17:21:25 +01:00
.editorconfig Project setup 2020-09-03 10:05:46 +02:00
.gitignore Add .gitignore for Nim compiled files 2020-09-07 16:32:28 +02:00
.tool-versions Project setup 2020-09-03 10:05:46 +02:00
Readme.md Introduce Connection.waitClosed() 2021-01-04 10:05:34 +01:00
lint.nims Add linter to format source files 2020-11-25 18:00:32 +01:00
nim.cfg Include Defect in the list of allowed exceptions 2020-09-30 09:20:32 +02:00
quic.nim Remove everything but the API from the main module 2021-01-04 10:05:34 +01:00
quic.nimble Use package asynctest 2021-01-13 09:03:18 +01:00

Readme.md

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.