No description
Find a file
2025-11-05 07:53:12 -04:00
.github fix(tests): remove unittest2Compat flag (#157) 2025-10-17 13:38:48 -03:00
quic fix: fire timeout (#175) 2025-11-03 13:22:41 +00:00
tests fix: fire timeout (#175) 2025-11-03 13:22:41 +00:00
.editorconfig Project setup 2020-09-03 10:05:46 +02:00
.gitignore stream states improvements (#107) 2025-08-26 14:04:31 +02:00
.tool-versions chore: add initial logging (#42) 2024-08-14 16:07:26 +02:00
config.nims refactor(conn state): specify raised error and fix for method overriding (#137) 2025-10-07 17:20:54 +02:00
nim.cfg chore: add support for Nim 2 (#51) 2024-09-10 18:46:19 +02:00
quic.nim Remove everything but the API from the main module 2021-01-04 10:05:34 +01:00
quic.nimble feat: 0.5.2 2025-11-05 07:53:12 -04:00
README.md chore(readme): updated (#128) 2025-09-25 14:42:26 +00:00

QUIC for Nim

An implementation of the QUIC protocol in Nim.

Building and testing

Install dependencies:

nimble install -d

Run tests:

nimble test

Examples

Import quic and the chronos async library:

import quic
import chronos

Create server:

let tlsConfig = TLSConfig.init(cert, certPrivateKey, @["alpn"], Opt.none(CertificateVerifier))
let server = QuicServer.init(tlsConfig)

Accept incoming connections:

let address = initTAddress("127.0.0.1:12345")
let listener = server.listen(address)
defer:
  await listener.stop()
  listener.destroy()

while true:
  let connection =
    try:
      await listener.accept()
    except CatchableError:
      return # server stopped
  let stream = await connection.incomingStream()
  
  # read or write data to stream
  let data = await stream.read()

  await stream.close()
  await connection.waitClosed()

Create client:

let tlsConfig = TLSConfig.init(cert, certPrivateKey, @["alpn"], Opt.none(CertificateVerifier))
let client = QuicClient.init(tlsConfig)

Dial server and send message:

let address = initTAddress("127.0.0.1:12345")
let connection = await client.dial(address)
defer:
  await connection.close()

let stream = await connection.openStream()
let message = cast[seq[byte]]("hello form nim quic client")
await stream.write(message)
await stream.close()

Thanks

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