Richard Ramos 6d8678a159 feat: 0.5.2
2025-11-05 07:53:12 -04:00
2025-11-03 13:22:41 +00:00
2025-11-03 13:22:41 +00:00
2025-11-05 07:53:12 -04: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.

Description
No description provided
Readme 2.4 MiB
Latest
2025-05-29 09:59:27 -04:00
Languages
Nim 100%